My Emacs Configuration (Dired)
My Emacs Configuration: Mastering Dired
Dragon's notes | 📅 05 Jul 2026 | 🏷️ #emacs
This article is a continuation of my series exploring my Emacs setup. If you missed the earlier entries, you can find them here:
- My Emacs configuration (common parts)
- Why and how I ditched use-package?
Rather than providing a dry list of configuration settings—which is common in many blog posts—I want to dive into my daily habits and the specific workflows I employ while using Dired.
What is Dired? For those unfamiliar, Dired is an Emacs package that functions as a high-powered file manager. It treats directories as standard Emacs buffers, allowing you to manipulate your files and folders using the same keyboard shortcuts and editing habits you use for text.
🛠️ The Preamble: My Evolution
I have always leaned toward a minimalist computing environment. My journey toward Dired looked something like this:
Initially, I relied on the command line bash and zsh for almost everything. While efficient, I craved more interactivity. I wanted to move or copy files between directories without typing repetitive cp commands or to view two directories simultaneously (similar to the dual-pane view in Midnight Commander).
However, I needed even more—specifically, the ability to preview images. Midnight Commander couldn't provide the plugin flexibility I found in tools like Far. Since Dired comes bundled with nearly every Emacs distribution, I decided to give it a shot. I haven't looked back since.
🚀 Invoking Dired
I generally access Dired through a few different pathways depending on the context:
1. Project-Based Navigation
When working within a project, I use specific hotkeys to jump to directories:
C-x p d: Jump to a specific catalog within the project.- Example: To open my configuration folder, I type
C-x p d configs RET.
- Example: To open my configuration folder, I type
C-x p D: Open the project's root directory immediately.
2. Contextual Access
If I am currently editing a blog post and need to manage its associated assets (like images), I use:
C-x C-j Opens the Org file and image buffer.
3. General & Remote Access
I have rebound the default C-x d to C-x C-d for better ergonomics:
(keymap-global-set "C-x C-d" 'dired)
This is my go-to for local folders or remote servers via TRAMP. For instance, to access a bin folder on a remote server:
C-x C-d /ssh:username@server.example.com:~/bin
Note: Upon entering the colon, GnuPG prompts for my private key password to decrypt ~/.authinfo.gpg, which stores the server credentials.
4. System Integration
I have configured Emacs to act as my system's default file manager. For example, in Librewolf, clicking the folder icon in the "Downloads" menu triggers an Emacs frame to open the corresponding Dired buffer. (See my previous guide: Emacs Dired as a default file manager).
📂 File Operations
Managing files in Dired is intuitive. While the m key is the standard for marking files, there are far more sophisticated methods available.
Marking Strategies
| Keybinding | Action |
|---|---|
* s | Mark all files and directories |
* . | Mark files with a specific extension |
% m | Mark files matching a regular expression |
U | Unmark all files |
t | Toggle marks |
Practical Examples
Example A: Deleting specific formats
If my cursor is on a .webp file, I can quickly delete all such files using the sequence:
* . RET D y RET.
(Note: These are separate commands; the extension is pre-selected if the cursor is already on a matching file).
Example B: Batch Conversion I personally dislike WEBP as a corporate format, so I convert them to JPG using GraphicsMagick:
- Press
* .to select WEBP files. - Use
M-nto cycle through my saved special commands. - Select the
? .jpgcommand and pressEnter.
Example C: The Power of Regexp
The % m command is where Dired truly outshines the CLI or Midnight Commander. I can select files using complex patterns. For example, to find files starting with e6f and ending in .webp or a 3-letter extension variant:
^e6f.+\.webp\.?\([a-z]\{3\}\)?
In mathematical terms, the selection logic follows:
🚩 Marks vs. Flags
It is important to distinguish between marking and flagging. Dired allows you to do both simultaneously:
- Marks (Purple): Used for copying or moving files.
- Flags (Red): Used specifically for deletion (triggered by the
dkey).
This separation allows me to mark a set of files for backup while simultaneously flagging others for removal, each visually distinct in the buffer.
There are, of course, many more keybindings...