summaryrefslogtreecommitdiffstats
path: root/content/posts/dired-expand-dir-on-tab/index.org
blob: 7e189e34650869b148e52e03515ef8a23587439e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#+TITLE: Expanding a Directory With Tab in Dired Mode
#+DATE: 2020-06-25T12:02:59-04:00
#+DRAFT: true
#+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: <kbd>Tab ↹</kbd>@@ key. Pressing
@@html: <kbd>Tab ↹</kbd>@@ again on the same entry will collapse it
and hide the contents again.