Skip to main content

26.7 Hideshow minor mode

Hideshow mode is a buffer-local minor mode that allows you to selectively display portions of a program, which are referred to as blocks. Type M-x hs-minor-mode to toggle this minor mode (see Minor Modes).

When you use Hideshow mode to hide a block, the block disappears from the screen, to be replaced by an ellipsis (three periods in a row). Just what constitutes a block depends on the major mode. In C mode and related modes, blocks are delimited by braces, while in Lisp mode they are delimited by parentheses. Multi-line comments also count as blocks.

Hideshow mode provides the following commands:

C-c @ C-h​

C-c @ C-d​

Hide the current block (hs-hide-block).

C-c @ C-s​

Show the current block (hs-show-block).

C-c @ C-c​

C-c @ C-e​

Either hide or show the current block (hs-toggle-hiding).

S-mouse-2​

Toggle hiding for the block you click on (hs-mouse-toggle-hiding).

C-c @ C-M-h​

C-c @ C-t​

Hide all top-level blocks (hs-hide-all).

C-c @ C-M-s​

C-c @ C-a​

Show all blocks in the buffer (hs-show-all).

C-u n C-c @ C-l​

Hide all blocks n levels below this block (hs-hide-level).

These variables can be used to customize Hideshow mode:

hs-hide-comments-when-hiding-all​

If non-nil, C-c @ C-M-h (hs-hide-all) hides comments too.

hs-isearch-open​

This variable specifies the conditions under which incremental search should unhide a hidden block when matching text occurs within the block. Its value should be either code (unhide only code blocks), comment (unhide only comments), t (unhide both code blocks and comments), or nil (unhide neither code blocks nor comments). The default value is code.