Sidebar Directory Trees in Emacs
If you use Emacs, there are various choices for navigating the file system. This is a recap of the main choices.
The first option is dired, which allows one to navigate a file hierarchy using the keyboard. Dired is built-in in Emacs.
Dired can also be effectively used as a sidebar, by minimizing the information dired shows. Proceed as follows:
- Split the frame vertically (
C-x 3) and resize it
- Open a dired in the left (or right) frame using (
- Select “Hide details” from the menubar (“Immediate” -> “Hide details”)
The advantage is that you get all the functions dired offers. However, you need to use sticky-windows (see below), if you want the sidebar to stick on the frame.
Dired sidebar is a minor mode that leverages ‘dired’ to emulate a tree browser.
This minor mode automates the process described for displaying dired in a sidebar.
Used in conjunction with dired-subtree this mode allows to navigate the file system hierarchically while getting all the benefits of dired.
A third possibility is using speedbar, which ships with Emacs.
Speedbar offers various navigation capabilities (files, buffers, org-mode sections, info files), which makes the mode very flexible.
Three aspects I do not particularly like about this function:
- the speedbar runs in its own frame: this makes the use of speedbar difficult when you start moving windows around. See sr-speedbar below, though.
- clicking on the icon of a directory has a different effect than clicking on the directory name. In the first case, speedbar shows the content of the directory in a subtree; in the latter, speedbar changes the root of the filetree to the clicked directory
- by default only the directories are shown (no files). This can be easily changed in the preferences, though
sr-speedbar runs a speedbar as a left or right sidebar (window, using Emacs terminology) in the current frame.
This makes speedbar a lot more usable, in my opinion, but some of the “oddities” of the speedbar still remain.
Neotree is a Emacs tree plugin like NerdTree for Vim.
Simple and intuitive. The only critique is that it blocks the size of the frame and long filenames are only partially shown. This is, however, similar to what other modes do.
A Useful command is
C-c C-c to change the root of the currently shown tree.
ZTree is a project dedicated to implementation of several text-tree applications inside GNU Emacs. It consists of 2 subprojects: ztree-diff and ztree-dir (the basis of ztree-diff).
The latter can be used to navigate a file tree in a buffer.
Treemacs is a file and project explorer in the same vein as NeoTree or vim’s NerdTree. It shows the file system outline in a simple tree layout allowing quick navigation and exploration, while also possessing basic file management utilities.
sr-speedbar, with a more modern look and more functions. For
instance, it recognizes sections and symbols in formatted text (such as
Markdown) and source code.
emacs-dirtree used to show a directory tree, but I have not been able to make it run on recent versions of Emacs.