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.
- Done. Display last buffer. (call
kill-bufferif you actually want to close it.)
- Copy file
- Rename/move file
- Delete file or directory
- Create new dir
- Compress/decompress the file by gzip
Note: you can have copy command automatically select the target dir in a split pane.
(setq dired-dwim-target t).
[see Emacs: Dired Customization]
Mark/Unmark Multiple Files
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: Regex Tutorial]
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
Emacs: Dired Customization
Put $5 at https://www.patreon.com/xahlee , or goto paypal.com and pay to Xah@XahLee.org . Message me on XahLee discord, say so, ask me questions.
Or Buy Xah Emacs Tutorial