I use hs-minor-mode, as recommended in a comment by Rorschach in the question. The hs-minor-mode came with my emacs install and it works well.
To determine the useful commands, I typed Ctrl-h v hs-minor-mode-map and examined the keyboard map when hs-minor-mode is active (I added the comments so that the actual key sequences are easily read):
(3 keymap ; Ctrl-C
(64 keymap ; @ (at-sign)
(5 . hs-toggle-hiding) ; Ctrl-E
(4 . hs-hide-block) ; Ctrl-D
(20 . hs-hide-all) ; SPACE
(1 . hs-show-all) ; Ctrl-A
(3 . hs-toggle-hiding) ; Ctrl-C
(12 . hs-hide-level) ; Ctrl-L
(27 keymap ; ESC
(19 . hs-show-all) ; Ctrl-S
(8 . hs-hide-all)) ; Ctrl-H
(19 . hs-show-block) ; Ctrl-S
(8 . hs-hide-block)))) ; Ctrl-H
The recommended keystrokes are difficult to type. I decided to assign Alt-H
to the following elisp (it's not exactly what I want yet, but I do like to assign one keystroke to do multiple things):
(lambda () (interactive)
(hs-minor-mode 1)
(if (hs-find-block-beginning)
(hs-toggle-hiding)
(let ((from (point-min))
(to (point-max)))
(while (and
(not (hs-overlay-at from))
(setq from (next-overlay-change from))
(not (= to from)))) ; locate first hs-overlay
(if (= to from) ; hs-overlay-was-not-found
(hs-hide-all)
(hs-show-all))))))