30.17 Editing the Dired Buffer
Wdired is a special mode that allows you to perform file operations
by editing the Dired buffer directly (the “W” in “Wdired” stands
for “writable”). To enter Wdired mode, type C-x C-q
( dired-toggle-read-only
) while in a Dired buffer.
Alternatively, use the ‘ Immediate / Edit File Names
’ menu item.
While in Wdired mode, you can rename files by editing the file names
displayed in the Dired buffer. All the ordinary Emacs editing
commands, including rectangle operations and query-replace
, are
available for this. Once you are done editing, type C-c C-c
( wdired-finish-edit
). This applies your changes and switches
back to ordinary Dired mode.
Apart from simply renaming files, you can move a file to another directory by typing in the new file name (either absolute or relative). To mark a file for deletion, delete the entire file name. To change the target of a symbolic link, edit the link target name which appears next to the link name.
If you edit the file names to create a new subdirectory, Wdired will
automatically create these new directories. To inhibit this behavior,
set wdired-create-parent-directories
to nil
.
The rest of the text in the buffer, such as the file sizes and
modification dates, is marked read-only, so you can’t edit it.
However, if you set wdired-allow-to-change-permissions
to
t
, you can edit the file permissions. For example, you can
change ‘ -rw-r--r--
’ to ‘ -rw-rw-rw-
’ to make a file
world-writable. These changes also take effect when you type C-c C-c
.