#+TITLE: Expanding a Directory With Tab in Dired Mode #+DATE: 2020-06-25T12:02:59-04:00 #+DRAFT: false #+DESCRIPTION: How to setup Emacs to expand dired directories on TAB #+TAGS[]: emacs #+KEYWORDS[]: emacs dired #+SLUG: #+SUMMARY: #+ATTR_HTML: :alt dired-subtree expanded #+ATTR_HTML: :title dired-subtree Expanded [[file:dired-subtree.png]] =dired= mode is one of my favourite features of Emacs. I use it so often, it's pretty much my go-to file browser. I use it both on my local machine, and on remote machines via TRAMP. One feature of =dired= is the ability to enter sub-directories in the same buffer by inserting the contents under the current directory. While this is useful, I often want something quicker to check the contents of a directory without either opening it in a new buffer, or inserting it below. The workaround for this I use is by using the excellent [[https://melpa.org/#/dired-subtree][dired-subtree]] package and the following ~use-package~ definition. #+BEGIN_SRC elisp (use-package dired-subtree :ensure t :after dired :bind (:map dired-mode-map ("TAB" . dired-subtree-toggle))) #+END_SRC Now whenever I want to expand a directory, I move my cursor over it and press the @@html: Tab ↹@@ key. Pressing @@html: Tab ↹@@ again on the same entry will collapse it and hide the contents again.