M-x all-things-emacs

Quick Tip: Reuse Dired Buffers

February 25th, 2007 by Ryan McGeary · 159 Comments

By default, dired creates new buffers when visiting new directories. Sometimes this is desired, especially when you need to visualize the contents of two separate directories; however, when you’re just navigating around, all the extra buffers tend to clutter your buffer list.

Typical navigation is done with dired-find-file (bound to f, RET, or e) or dired-find-file-other-window (bound to o). When performed on a directory, this visits the directory in a new dired buffer. In Emacs 22, instead try running dired-find-alternate-file (bound to a). This replaces the current buffer keeping the clutter of dired buffers to a minimum.

When you run dired-find-alternate-file for the first time, you’ll receive a warning that the function is disabled. You can either follow the built-in instructions and customizations to enable the function, or you can add the following to your .emacs.

(put 'dired-find-alternate-file 'disabled nil)


GNU Emacs Manual, Visiting Files in Dired

EmacsWiki, DiredReuseDirectoryBufferincludes other ways to enable similar behavior in Emacs 21.

Tags: dired · quick · tips

159 responses so far ↓

  • 1 Eric // Feb 26, 2007 at 4:39 pm

    I always figured it was possible, but never got around to looking into it. Thanks!