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 OS desktop for these tasks.

M-x dired . emacs's feature for file management.

“dired” is short for Directory Edit. It is a old term for file management.

{Copy, Delete, Rename} File

To start viewing directory, called dired .

When in dired, most commands have a single letter key.

emacs dired “Operate” menu

Here's the most useful commands:

dired-find-file 【 Enter 】 → Open the file or directory.

【 】 → Open the file or directory. quit-window 【 q 】 → Done. Display last buffer. (call kill-buffer if you actually want to close it.)

dired-do-copy 【 C 】 → Copy file

【 】 → Copy file dired-do-rename 【 R 】 → Rename/move file

【 】 → Rename/move file dired-do-delete 【 D 】 → Delete file or directory

【 】 → Delete file or directory dired-create-directory 【 + 】 → create new dir

【 】 → create new dir dired-do-compress 【 Z 】 → compress/decompress the file by gzip

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.

dired mark menu

To mark a file, press m .

Here's a list of basic marking commands:

dired-mark 【 m 】 → mark a file

【 】 → mark a file dired-unmark 【 u 】 → unmark

【 】 → unmark dired-unmark-all-marks 【 U 】 → unmark all marked

【 】 → unmark all marked dired-mark-files-regexp 【 % m 】 → mark by pattern (regex)

For example, if you want to mark all HTML files, type % m , then type \.html$ .

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.

Dired Navigation

Here are other common dired commands:

revert-buffer 【 g 】 → refresh dir listing

【 】 → refresh dir listing dired-up-directory 【 ^ 】 → go to parent dir

【 】 → go to parent dir dired-next-dirline 【 > 】 → Move cursor to next subdirectory.

【 】 → Move cursor to next subdirectory. dired-prev-dirline 【 < 】 → Move cursor to previous subdirectory.

dired is often used together with shell-command 【 Alt + ! 】 or shell . [see Emacs: Run Shell in Emacs]

For complete list of dired commands, Alt + x describe-mode when in dired-mode.

(info "(emacs) Dired")

Dired Customization

Emacs: Dired Customization