Emacs: File Manager, dired

By Xah Lee. Date: . Last updated: .

What is Dired

Dired is a emacs feature to manage files. (dired stand for “Directory Edit”. Its an old term for file management.)

Dired lets you list files, copy, delete, rename, move, or create, delete, file or directory. It is better than using shell commands. Visual control, less errors, more efficient (less keystrokes).

Start Dired

To start viewing directory, Alt+x dired.

emacs dired menu 2021-07-19
emacs dired

Exit Dired

quit-windowq

hide the dired buffer. (when you are done) Display last buffer.

or, you can just kill-buffer to close the buffer.

Copy, Delete, Rename File

Here's the most useful commands:

dired-find-fileEnter

Open the file or directory.

dired-do-copyC

Copy file

dired-do-renameR

Rename/move file

dired-do-deleteD

Delete file or directory

dired-create-directory+

Create new dir

dired-do-compressZ

Compress or decompress the file by gzip

Mark Files

You can mark the files, then apply a command on all marked files.

dired mark menu 2021-07-19
dired mark menu

basic marking commands:

dired-markm

Mark a file

dired-unmarku

Unmark

dired-unmark-all-marksU

Unmark all marked

dired-mark-files-regexp% m

Mark by Regular Expression. e.g. % m, then type jpg$, mark all jpeg image files.

Dir Navigation

revert-bufferg

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-jump

dired-jumpCtrl+x Ctrl+j

go to dired of the current file, and place cursor on the file.

if in dired, it goes to the parent dir.

💡 TIP: with this command, you never have to call dired and manually type a path. It is efficient to always goto dired by this method. Emacs: Bookmark files, not dirs. Change your workflow to file based, not dir based.

Dired Help

When in dired, Alt+x describe-mode

Emacs Dired, File Management

Emacs, File and Buffer