Emacs: File Manager, dired
What is Dired
Emacs is a excellent tool for file management. e.g. list files, copy, delete, rename, move, or create, delete directory.
“dired” is short for Directory Edit. It is a old term for file management.
Start Dired
To start viewing directory, Alt+x dired
.
When in dired, most commands have a single letter key.
Copy, Delete, Rename File
Here's the most useful commands:
dired-find-file
【Enter】- Open the file or directory.
quit-window
【q】- hide the dired buffer. (when you are done) Display last buffer.
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/decompress the file by gzip
Mark Files for an Operation
Sometimes you want to copy or delete many files. You can mark the files, then apply a command on all marked files.
Here's 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 regex. [see Emacs: Regular Expression]
For example, if you want to mark all HTML files, type % m, then typehtml$
.
- 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.
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 Help
When in dired, Alt+x describe-mode