show org-mode outline up to a certain heading level

If the prefix arguments from M. Kullman's answer take too much mental capacity for you (a limited resource when you are thinking hard about something else at the same time) then you can use the following functions to expand contract headings

(defvar hf-org-depth-point nil)
(defvar hf-org-depth-depth nil)

(defun hf-org-depth-increase ()
   (interactive)
   (hf-org-depth-incr 1))

(defun hf-org-depth-decrease ()
    (interactive)
    (hf-org-depth-incr -1))

(defun hf-org-depth-incr (incr)
    (when (not (equal (point) hf-org-depth-point))
        (setq hf-org-depth-point nil)
        (setq hf-org-depth-depth 0))a
    (setq hf-org-depth-point (point))
    (setq hf-org-depth-depth (max (+ hf-org-depth-depth incr) 0))
    (hide-subtree)
    (show-children hf-org-depth-depth))

```


I am way late to the party, but let us add a simple way for posterity. Simply use Cycle Global Visibility (<backtab>). If your headings are open, it will close them. However, if you apply it repeatedly with all headings collapsed, they will open to the level you want.

I use it from the keyboard by <SHIFT>+<TAB>. You can also find it in the Org menu (in Emacs) under Show/Hide -> Cycle Global Visibility ()


Just stumbled on this question. One year later but what the heck.. There are commands for this that allows you to show headings to a certain level.

One command is C-<n> C-c tab will show subheadings up to level <n> (<n>=1,2,3...).

Another command is C-<n> S-tab which will operate on the whole buffer. It shows all headings up to level <n> (<n>=1,2,3...)


I found a solution that suits me: The command org-content shows the folder hierarchy, and giving it a numeric argument does exactly what I want: limit the maximum level shown. In my example, I wanted to show 2 levels, so I can do C-2 M-x org-content <RET>.

I also added my own command to my .emacs init file, binding that command to C-c m

(defun org-show-two-levels ()
  (interactive)
  (org-content 2))

(add-hook 'org-mode-hook
  (lambda ()
    (define-key org-mode-map "\C-cm" 'org-show-two-levels)))