10 KiB
10 KiB
Doom Emacs File Explorer Cheatsheet
🗂️ What is Dired?
Dired (Directory Editor) is Emacs' built-in file manager that allows you to navigate, manage, and manipulate files and directories efficiently.
- Browse directories with keyboard navigation
- Mark, copy, move, and delete files
- Execute commands on multiple files at once
- Integrate with other Emacs tools and buffers
📋 Requirements
- Doom Emacs (Dired is built-in)
- Treemacs: Must be enabled in
~/.doom.d/init.el(uncommenttreemacsline) - Optional tools for enhanced functionality:
rsync- Fast file synchronization and copyingfdorfind- Enhanced file findingrg(ripgrep) orag(the_silver_searcher) - Fast text searchexaorlsd- Enhanced directory listingstrash-cli- Safe file deletion to trashzip/unzip,tar,gzip- Archive handling
⌨️ Opening File Explorers
Dired (Built-in File Manager):
SPC .- Open Dired in current directorySPC f d- Find directory (open Dired in specific path)C-x d- Open Dired (classic Emacs binding)
Project File Navigation:
SPC SPC- Find file in projectSPC f f- Find file anywhereSPC f r- Recent filesSPC p f- Find file in project
Tree-style Explorers:
SPC o p- Toggle project sidebar (Treemacs)SPC f t- Find file in tree
🧭 Navigation in Dired
Basic Movement:
j/korn/p- Move up/down between filesh- Go up one directory (parent)lorRET- Enter directory or open file^- Go to parent directoryg- Refresh directory listing
Jumping Around:
gg- Go to top of listingG- Go to bottom of listing/- Search for file/directory nameSPC s s- Search within directory
File Information:
(- Toggle details (show/hide file info)s- Sort files (by name, date, size)C-h m- Show help for current mode
📁 File Operations
Opening Files:
RET- Open file in current windowo- Open file in other windowC-o- Open file in other window (keep cursor in Dired)v- View file (read-only)f- Find file (same as RET)
Creating Files & Directories:
+- Create directorySPC f c- Create file (when in Dired buffer)C-x C-f- Find/create file (from Dired)
🏷️ Marking Files
Basic Marking:
m- Mark file for operationsu- Unmark fileU- Unmark all filest- Toggle marks (mark unmarked, unmark marked)* %- Mark by regex pattern
Quick Marking:
* .- Mark by extension (e.g., *.txt)* /- Mark directories* @- Mark symlinks* *- Mark executables
Advanced Marking:
% m- Mark files matching regex% d- Mark for deletion files matching regex* c- Change marks (change one mark to another)
✂️ File Management Operations
Copy, Move, Delete:
C- Copy marked files (or file under cursor)R- Rename/Move marked filesD- Delete marked files immediatelyd- Mark for deletion (usexto execute)x- Execute deletions (delete files marked withd)
Deletion Options:
dthenx- Safe deletion (mark first, then execute)D- Immediate deletion (bypass mark step)- Trash integration: If
trash-cliis installed, files go to trash instead of permanent deletion
Advanced Operations:
Z- Compress/uncompress files (usesgzip,zip,tarautomatically)A- Search in marked files (usesgreporrgif available)Q- Query replace in marked files!- Run shell command on marked files&- Run async shell command on marked files
📋 Copying & Moving
Copy Operations:
C- Copy files (prompts for destination)- Works with marked files or single file under cursor
- Uses
rsyncif available for faster, resumable copying - Supports copying to different drives/partitions
Move/Rename Operations:
R- Rename/Move files- Can rename single files or move multiple marked files
- Supports moving across directories
Tips for Copy/Move:
- Mark multiple files first, then use
CorR - Tab completion works for destination paths
- Use relative paths (
.,..) for quick navigation
🔍 Search & Filter
Finding Files:
/- Search file names in current listingn/N- Next/previous search match
Enhanced Search (with external tools):
A- Search inside files (usesrg>ag>grepin priority order)- Much faster with
ripgreporthe_silver_searcher - Supports regex patterns and file type filtering
Filtering Display:
(- Toggle detailed views- Sort by different criteriaC-u s- Sort with custom options
Content Search:
A- Search inside marked filesQ- Query replace across marked files
🔧 Advanced Features
Wdired (Writable Dired):
C-x C-q- Edit filenames directly (like renaming)- Edit filenames as text, then
C-c C-cto apply changes C-c C-kto cancel edits
Multiple Windows:
o- Open in other windowC-o- Display in other window (stay in Dired)2- Split window vertically for two Dired views
Subdirectories:
i- Insert subdirectory in same buffer$- Hide/show subdirectory contentsM-$- Hide all subdirectories
📊 File Comparison
Diff Operations:
=- Diff file with anotherM-=- Diff marked files against each other- Works with external diff tools
🗜️ Archive Operations
Compression & Archives:
Z- Compress/decompress automatically detects format- Supports:
.gz,.zip,.tar,.tar.gz,.tar.xz,.7z - Uses appropriate tools:
gzip,zip,tar,7z
Archive Viewing:
- Open
.zip,.tar, etc. files directly to browse contents - Extract specific files from archives
🎛️ Customization & Settings
View Options:
(- Toggle between simple and detailed views- Cycle through sort orders (name, date, size)- Enhanced listings with
exaorlsdif available
Useful Settings:
- Dired reuses buffers by default in Doom
- Auto-refresh on file changes
- Integration with Evil mode keybindings
⚡ Treemacs (Tree Explorer)
Basic Treemacs:
SPC o p- Toggle Treemacs sidebarj/k- Navigate up/down in treeRET- Open file or expand/collapse directoryTAB- Expand/collapse directory
Treemacs File Operations:
cf- Create filecd- Create directoryR- Renamed- Deleteyy- Copy path to clipboard
🚀 Quick Start Workflow
Basic File Management:
- Press
SPC .- Open Dired in current directory - Navigate with
j/k- Move between files - Mark files with
m- Select multiple files - Use
Cto copy orRto move/rename - Press
gto refresh when done
Efficient File Operations:
- Mark multiple files with
m - Execute batch operations (
Cfor copy,Rfor move) - Use
!to run shell commands on marked files - Toggle details with
(for more/less information
📚 Essential Keybind Summary
| Action | Key | Description |
|---|---|---|
| Open Dired | SPC . |
Open file explorer |
| Navigate | j/k |
Move up/down |
| Enter/Open | RET or l |
Open file/directory |
| Parent Dir | h or ^ |
Go up one directory |
| Mark | m |
Mark file for operations |
| Copy | C |
Copy marked files |
| Move/Rename | R |
Move or rename files |
| Delete | d then x |
Mark for deletion, execute |
| Create Dir | + |
Create new directory |
| Compress | Z |
Compress/decompress |
| Search Files | A |
Search inside files |
| Refresh | g |
Refresh directory listing |
| Help | ? |
Show available commands |
🔧 Troubleshooting
Common Issues:
- Dired buffer not updating? Press
gto refresh - Can't see file details? Press
(to toggle detailed view - Operations feel slow? Use marking (
m) for batch operations - Wrong sort order? Press
sto cycle through sort options
Performance Tips:
- Install
fdfor faster file finding - Install
rg(ripgrep) for faster text search - Use
rsyncfor efficient file copying - Consider
exaorlsdfor enhanced directory listings
Getting Help:
?- Context help in any Dired bufferC-h m- Mode-specific helpSPC h d f dired- Full Dired documentation
📋 Comparison: Dired vs Treemacs
Use Dired when:
- Managing multiple files at once
- Need detailed file information
- Performing batch operations
- Working with file permissions/ownership
Use Treemacs when:
- Quick project overview
- Simple file navigation
- Prefer visual tree structure
- Need persistent sidebar
🛠️ External Tool Integration
Recommended Tools:
rsync- Fast, reliable file copying with resume capabilityripgrep(rg) - Extremely fast text search, much faster than grepfd- Fast alternative to find with better defaultsexa- Modern replacement for ls with colors and git integrationtrash-cli- Safe deletion to trash instead of permanent removal7z- Handle 7zip archives and other compression formats
Installation (Debian/Ubuntu):
sudo apt install rsync ripgrep fd-find exa trash-cli p7zip-full
🎯 Pro Tips
- Batch operations: Mark files first (
m), then execute operations - Quick navigation: Use
/to search for files by name - Edit filenames: Use
C-x C-qfor Wdired mode to rename multiple files - Shell integration: Use
!to run shell commands on files - Multiple directories: Use
ito show subdirectories in same buffer - Safe deletion: Install
trash-clito send files to trash instead of permanent deletion - Fast search: Install
ripgrepfor lightning-fast text search in files
Dired provides a comprehensive file management experience that integrates well with external Linux tools, making file operations both efficient and powerful.