Emacs: File Manager, dired
What is Dired
Dired is a emacs feature to manage files. (dired stand for “Directory Edit”. Its an old term for file management.)
Dired lets you list files, copy, delete, rename, move, or create, delete, file or directory. It is better than using shell commands. Visual control, less errors, more efficient (less keystrokes).
Start Dired
To start viewing directory, Alt+x dired
.
Exit Dired
quit-window
【q】-
hide the dired buffer. (when you are done) Display last buffer.
or, you can just
kill-buffer
to close the buffer.
Copy, Delete, Rename File
Here's the most useful commands:
dired-find-file
【Enter】-
Open the file or directory.
dired-do-copy
【C】-
Copy file
dired-do-rename
【R】-
Rename/move file
dired-do-delete
【D】-
Delete file or directory
dired-create-directory
【+】-
Create new dir
dired-do-compress
【Z】-
Compress or decompress the file by gzip
Mark Files
You can mark the files, then apply a command on all marked files.
- When there are marked files, dired command applies to the marked files.
- When no files are marked, dired command applies to the file under cursor.
basic marking commands:
dired-mark
【m】-
Mark a file
dired-unmark
【u】-
Unmark
dired-unmark-all-marks
【U】-
Unmark all marked
dired-mark-files-regexp
【% m】-
Mark by Regular Expression. e.g. % m, then type
jpg$
, mark all jpeg image files.
Dir Navigation
revert-buffer
【g】-
Refresh dir listing
dired-up-directory
【^】-
Go to parent dir
dired-next-dirline
【>】-
Move cursor to next subdirectory.
dired-prev-dirline
【<】-
Move cursor to previous subdirectory.
Shell Command on File
dired-do-shell-command
【! 】-
Prompt a shell command to run on the file the cursor is on.
dired-jump
dired-jump
【Ctrl+x Ctrl+j】-
go to dired of the current file, and place cursor on the file.
if in dired, it goes to the parent dir.
💡 TIP: with this command, you never have to call dired and manually type a path. It is efficient to always goto dired by this method. Emacs: Bookmark files, not dirs. Change your workflow to file based, not dir based.
Dired Help
When in dired, Alt+x describe-mode