Narrowing means focusing in on some portion of the buffer, making the rest temporarily invisible and inaccessible. Cancelling the narrowing and making the entire buffer once again visible is called widening. The amount of narrowing in effect in a buffer at any time is called the buffer’s restriction.
Narrow down to between point and mark (narrow-to-region
).
Widen to make the entire buffer visible again (widen
).
Narrowing sometimes makes it easier to concentrate on a single subroutine or paragraph by eliminating clutter. It can also be used to restrict the range of operation of a replace command or repeating keyboard macro. The word ‘Narrow’ appears in the mode line whenever narrowing is in effect. When you have narrowed to a part of the buffer, that part appears to be all there is. You can’t see the rest, can’t move into it (motion commands won’t go outside the visible part), and can’t change it in any way. However, the invisible text is not gone; if you save the file, it will be saved.
The primary narrowing command is C-x n n (narrow-to-region
).
It sets the current buffer’s restrictions so that the text in the current
region remains visible but all text before the region or after the region
is invisible. Point and mark do not change.
Because narrowing can easily confuse users who do not understand it,
narrow-to-region
is normally a disabled command. Attempting to use
this command asks for confirmation and gives you the option of enabling it;
once you enable the command, confirmation will no longer be required. See Disabling.
To undo narrowing, use C-x n w (widen
). This makes all
text in the buffer accessible again.
Use the C-x = command to get information on what part of the buffer you narrowed down. See Position Info.