7

One of the biggest things I miss from other editors (e.g. Sublime, Intellij) is the ability to see the project structure, and expand/minimize directories as needed so I can see what I care about. Is there something like Org mode hierarchy where I can use a hotkey to expand a subdirectory as needed?

10

In Dired you can include a subdirectory using i, with the cursor on the subdir line.

You can do likewise on a subdir line within a subdir listing, so you can list any number of levels of any number of subdirs in the same Dired buffer.

$ on a subdir-listing header line hides/shows that subdir listing. So it corresponds more or less with the expand/contract feature you requested. With a prefix arg (e.g. C-u $) it shows/hides everything, which basically gets you back to a clean slate, but with listing header lines where you can apply $ to selectively show their listings.

Know too that C-x C-v RET will refresh the main directory listing for a given Dired buffer. In other words, it starts over, reading the directory anew - no included subdir listings etc. On the other hand, g just refreshes the currently displayed listings, picking up any changes made outside Emacs.

You can use the same ls switches for any given subdir listing.

Dired does not provide a "tree" view of the directory hierarchy. But it is still quite useful.

If you use add-on library Dired+ then you get quite a bit more functionality, including commands that operate on marked files and marked files of marked subdirs, ... found recursively.

With Dired+, even just i is more useful - use it to bounce back and forth between a subdir line in a parent listing and the listing of that subdir.

Dired+ also makes it easy to use multiple Dired buffers, including separate buffers for different parts of a tree (e.g. different subdirs). And it lets you easily create listings of files and directories from anywhere, i.e., not from the same directory at all.

To explore and discover what you can do, use the menu-bar menus, starting with menu Dir.

3

dired-subtree is an option and looks as follows:

enter image description here

If using use-package, you can enable in your init.el and bind to TAB and SHIFT-TAB with:

(use-package dired-subtree :ensure t
  :after dired
  :config
  (bind-key "<tab>" #'dired-subtree-toggle dired-mode-map)
  (bind-key "<backtab>" #'dired-subtree-cycle dired-mode-map))

I wrote a little about it here.

  • 1
    Please expand on your post to make it a full, self-contained answer. We generally discourage link-only posts as answers; if you want me to convert your post to comment (where link-only is less of an issue), let me know. – Dan May 11 '16 at 11:38
  • Done. Hope that's better =) – alvaro Jun 2 '16 at 21:04
2

http://cedet.sourceforge.net/speedbar.shtml

Speedbar is an Emacs Lisp program which allows you to create a special skinny frame with a specialized directory listing in it. This listing will have both directories and filtered files in it. You can then load files into your emacs frame, or expand the files to display all the tags that are in them and jump to those tags. You can also expand multiple directories into your speedbar frame.

  • 1
    Even though the question specifically mentions dired, I suspect that speedbar will fit the criteria of OP very nicely, especially coming from other IDEs. Also, for those who don't like giving speedbar its own frame, check out Sr Speedbar which docks the speedbar in the current frame. – nispio May 10 '16 at 22:34

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.