Emacs: File Manager, dired
Emacs is a excellent tool for file management. For example, list files, copy/delete, rename, moving files, create/delete directory. Once you become familiar with it, you almost never go to shell or the Operating System file manager for these tasks.
“dired” is short for Directory Edit. It is a old term for file management.
To start viewing directory, Alt+x
When in dired, most commands have a single letter key.
Here's the most useful commands:
- Open the file or directory.
- hide the dired buffer. (when you are done) Display last buffer.
- Copy file
- Rename/move file
- Delete file or directory
- Create new dir
- Compress/decompress the file by gzip
Tip: you can have copy command automatically select the target dir in a split pane.
(setq dired-dwim-target t).
[see Emacs Init: Dired Config]
Mark Multiple 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:
- Mark a file
- Unmark all marked
Mark by regex. [see Emacs: Regular Expression]
For example, if you want to mark all HTML files, type % m, then type
- 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.
Here are other common dired commands:
- Refresh dir listing
- Go to parent dir
- Move cursor to next subdirectory.
- Move cursor to previous subdirectory.
Shell Command on File
- Prompt a shell command to run on the file the cursor is on.
When in dired, Alt+x