1

I often do the following sequence in my org-mode file:

  1. Go to the root headline from current position
  2. Fold the whole subtree

Is there a way to this sequence with a shortcut?

2

The following code (lightly tested) takes advantage of the fact that org-mode is derived from outline-mode, which allows you to use the latter's functions. It simply jumps up headlines until it can't go any further, and then hides the subtree.

(defun foldup ()
  "Hide the entire subtree from root headline at point."
  (interactive)
  (while (ignore-errors (outline-up-heading 1)))
  (hide-subtree))

Bind it to your key of choice if you use it frequently.

  • Exactly what I needed, thank you for the explanation as well! – asiegf Jun 17 '17 at 21:54

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.