14.17 Selective Display
Emacs has the ability to hide lines indented more than a given number of columns. You can use this to get an overview of a part of a program.
To hide lines in the current buffer, type C-x $
( set-selective-display
) with a numeric argument n. Then
lines with at least n columns of indentation disappear from the
screen. The only indication of their presence is that three dots
(‘ …
’) appear at the end of each visible line that is
followed by one or more hidden ones.
The commands C-n
and C-p
move across the hidden lines as
if they were not there.
The hidden lines are still present in the buffer, and most editing commands see them as usual, so you may find point in the middle of the hidden text. When this happens, the cursor appears at the end of the previous line, after the three dots. If point is at the end of the visible line, before the newline that ends it, the cursor appears before the three dots.
To make all lines visible again, type C-x $
with no argument.
If you set the variable selective-display-ellipses
to
nil
, the three dots do not appear at the end of a line that
precedes hidden lines. Then there is no visible indication of the
hidden lines. This variable becomes local automatically when set.
See also Outline Mode for another way to hide part of the text in a buffer.