How can I insert all the subdirectories of the toplevel directory in Dired?

And how can I insert the whole directory tree, i.e. all the subdirectories recursively?

I don't want to change the default switches, only to insert all the subdirectories just this once.

I'm not looking for C-u i and adding the R switch: that inserts subdirectories of the directory under the cursor. I want to insert all the subdirectories of the main directory.

  • 2
    You can call find-dired with no arguments. It will create a dired buffer with all files and directories under a given top level directory.
    – Juancho
    Sep 20, 2016 at 20:23
  • 2
    Try C-u s R RET.
    – politza
    Sep 20, 2016 at 20:34
  • To elaborate on @politza's really good suggestion: C-u s is a really useful dired command that lets you edit dired's ls switches.
    – vortek
    Mar 29, 2019 at 18:19

1 Answer 1


If you use library Dired+ then this is simple.

Just use M-+ M-i (command diredp-insert-subdirs-recursive).

Alternatively, use menu Multiple > Marked Here and Below > Insert Subdirs.

Dired+ has many commands that act on the marked files and the marked files in marked subdirectories, gathered recursively. And when none are marked, these commands act on all files in all subdirectories. All such commands are on prefix key M-+.

Even if some files or subdirs are marked, such commands ignore the markings and act on all files in all subdirectories if you provide a prefix argument.

diredp-insert-subdirs-recursive is an interactive compiled Lisp function in dired+.el.

(diredp-insert-subdirs-recursive &optional IGNORE-MARKS-P)

Insert the marked subdirs, including those in marked subdirs. Like diredp-insert-subdirs, but act recursively on subdirs. The subdirs inserted are those that are marked in the current Dired buffer, or ALL subdirs in the directory if none are marked. Marked subdirectories are handled recursively in the same way (their marked subdirs are inserted...).

With a prefix argument, ignore all marks - include all files in this Dired buffer and all subdirs, recursively.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.