I use quite a lot the useful command show-branches and I couldn't find the analogue command to hide all the branches under a certain Item. In other words my aim is to fold only a subtree and its parent. How to do this?

  • What exactly would this analogue do? Try C-h f hide- then TAB to see what functions are available. – JeanPierre Jan 29 '16 at 13:16
  • Have you tried org-cycle (TAB) and org-shifttab (shift and TAB together)? These will cycle back and forth between different levels of tree vicibility. – elethan Jan 29 '16 at 14:41
  • Yes! Everything gets folded! I would like to fold only a subtree and its parent. – falematte Jan 29 '16 at 16:16
  • 1
    (defun hide-subtree-and-parent () (interactive) (outline-up-heading 1) (hide-subtree)) then bind it to some key. – JeanPierre Jan 29 '16 at 20:11
  • Thank you this worked like a charm! Can you answer the question? :) – falematte Jan 29 '16 at 20:53

What you want is to fold a subtree and its parent. Doing C-h f hide- TAB shows there's apparently nothing doing exactly that, but there's a hide-subtree command:


Hide everything after this heading at deeper levels.

So you could go up one heading (move to the parent) and then hide-subtree. Let's define a (very simple) command to do that:

(defun hide-subtree-and-parent ()
  (outline-up-heading 1)

You can then bind this command to a key (here C-c h) if you use it very often.

(add-hook 'org-mode-hook 
   (lambda () (define-key org-mode-map "\C-ch" 'hide-subtree-and-parent)))
| improve this answer | |
  • This does not implement the right behaviour: if the current headline has a shown sister headline, that one is hidden too (but shouldn't). – Ivan Perez May 10 '18 at 13:28

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.