1

Pressing i on a subdirectory in the dired mode inserts that directory in the buffer. How can I remove it from the buffer?

3

TL;DR: Type C-uk on the subdirectory header line.

Quoth (emacs) Subdirectories in Dired:

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

and (emacs) Dired Updating:

   If you use ‘k’ to kill the line for a directory file which you had
inserted in the Dired buffer as a subdirectory (see Subdirectories in
Dired), it removes the subdirectory listing as well.  Typing ‘C-u k’
on the header line for a subdirectory also removes the subdirectory line
from the Dired buffer.

and (emacs) Hiding Subdirectories:

“Hiding” a subdirectory means to make it invisible, except for its
header line.

‘$’
     Hide or show the subdirectory that point is in, and move point to
     the next subdirectory (‘dired-hide-subdir’).  This is a toggle.  A
     numeric argument serves as a repeat count.

How I navigated the manual:

  1. C-hr (info-emacs-manual)
  2. i (Info-index)
  3. subdirTABRET (autocompletes to subdirectories in Dired)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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