Emacs – Dired

Introduction

Aside from editing files, including local and remote ones, Emacs can also play the role of a file manager, i.e., manipulating directories and the files by its directory editor, dired.

Enter dired buffer

Dired can be entered in following ways:

  • Command: M-x dired
  • Key bindings
    • C-x d is equivalent to the command above.
    • C-x 4 d open a dired buffer in another window.

Navigation

Key Description
^ Go up one directory
n/C-n Move the point down an entry
p/C-p Move the point up an entry
q Quit dired

Marking & unmarking

Marking and unmarking enable operations on multiple files or directories.

Key Description
m Mark the active entry or the selected region
u Unmark the active entry or the selected region
U Unmark everything
d Flag for deletion
t Toggle existing marking
* % Mark files and directories by regexp
* c Change marks
~ Mark backup files

Operations

Key Description
f/RET Visit the file/directory
v View the file/directory in read-only mode
g Refresh dired buffer
+ Create a directory
C Copy marked files/directories
R Rename/move marked files/directories
O Perform chown on marked files/directories
G Perform chgrp on marked files/directories
M Perform chmod on marked files/directories
D Delete marked files/directories
x Delete flagged (marked by d) files/directories

Working across directories

In dired buffer, typing i on a directory will insert it in the same dired buffer as a sub-directory.

By inserting multiple directories into a shared dired buffer, you can not only glance at multiple directories simultaneously but you can also work across them as if they were one large virtual directory.