emacs - dired
Table of Contents
Look at dired without leaving the current buffer
C-x d
Dired tips
(Alphabetical order)
Ctrl x Ctrl f | Visiting (opening) files. (This puts us in Emac’s dired mode - directory editor). To create a new file, just start typing the name of the file that you want to create. |
---|---|
g | Refresh the listing in dired mode |
m | mark a file in dired mode |
u | un-mark a file in dired mode |
U | un-mark all files |
w | When you are in dired mode, if you put the point on a file and press w, the name of the file will be copied into the kill ring. Makes it easier if you are trying to rename files. |
Ctrl x Ctrl q | Turn dired into editing mode. You can then edit the file names by hand or use M-% to replace foo with bar in the dired buffer. This will change the file names. Use C-c C-c so apply the changes, or C-c ESC to cancel |
d | Flag this file for deletion (dired-flag-file-deletion). |
C | copy a file |
R | rename/move a file |
D | delete a file |
u | Remove the deletion flag (dired-unmark). |
x | Delete files flagged for deletion (dired-do-flagged-delete). |
Supposing you wanted to delete a bunch of files, but wanted to see them first to visually check you are deleting the right ones, you might do the following:
- mark the files manually, or using a regular expression
- * t invert the selection
- k hide the selected files so now you see the ones you originally selected for deletion so you can check you got the right ones
- * s to select those visible files
- D to delete them
emacs - renaming files using dired
How to move a file using dired?
using wdired
- Exit
evil-mode
if you are using it - Alt-x
dired-toggle-read-only
- Make the changes to file names using regular emacs operations, rectangles, etc.
- Alt-x
wdired-finish-edit
Using regular dired
- Using
w
, copy the name of the file. - Hit
R
to rename the file - Change the path
- Use help from the mini-buffer to navigate to the exact path where you want to move the file.
- In the directory where you want to place the file, paste the file name using
Ctrl y
- The file will be moved there.
How to duplicate a file in dired?
https://www.gnu.org/software/emacs/manual/html_node/emacs/Operating-on-Files.html
- If you want to use the exact file name or use the initial file name with minimal changes, use
w
first to grab the name of the file. - Hit
C
- Specify the path and filename of the duplicate file to be created.
- Use help from the mini-buffer to navigate to the exact path where the copy is supposed to be placed.