ErgoEmacsEmacsLispBlogEmacsLispBuy Tutorial
Web Hosting by 1&1

37.11 Subdirectories in Dired

A Dired buffer displays just one directory in the normal case; but you can optionally include its subdirectories as well.

The simplest way to include multiple directories in one Dired buffer is to specify the options ‘-lR’ for running ls. (If you give a numeric argument when you run Dired, then you can specify these options in the minibuffer.) That produces a recursive directory listing showing all subdirectories at all levels.

More often, you will want to show only specific subdirectories. You can do this with the i command:

i
Insert the contents of a subdirectory later in the buffer.

Use the i (dired-maybe-insert-subdir) command on a line that describes a file which is a directory. It inserts the contents of that directory into the same Dired buffer, and moves there. Inserted subdirectory contents follow the top-level directory of the Dired buffer, just as they do in ‘ls -lR’ output.

If the subdirectory's contents are already present in the buffer, the i command just moves to it.

In either case, i sets the Emacs mark before moving, so C-u C-<SPC> takes you back to the old position in the buffer (the line describing that subdirectory). You can also use ‘^’ to return to the parent directory in the same Dired buffer.

Use the l command (dired-do-redisplay) to update the subdirectory's contents. Use C-u k on the subdirectory header line to delete the subdirectory (see Dired Updating). You can also hide and show inserted subdirectories (see Hiding Subdirectories).

blog comments powered by Disqus