narrowing buffer contents





'Narrowing' is yet another of those many useful emacs features that took me
years to appreciate, mostly because I never really tried it. I may not be the
only one, so here's a short introduction.



Narrowing is the concept of hiding the buffer contents except for what you
are currently working on. This is useful when you don't want to be distracted,
but also because it allows you to execute commands only on the narrowed
part. You can narrow different things:

















what's shownnamebinding
region (selection)narrow-to-regionC-x n n
current pagenarrow-to-pageC-x n p
functionnarrow-to-defunC-x n d
everythingwidenC-x n w




I never used narrowing for the current page, but apparently it's used by
e.g. Info-Mode to show only one page.



That last one is pretty important to remember; it's not totally obvious how
to get back to 'normal' mode where you can see everything. For this very
reason ('where the #>*$@ did my text go'), always-helpful emacs by defaults
disables narrow-to-region (but, for some reason, not the other ones). To
enable it, put the following in your .emacs:





(put 'narrow-to-region 'disabled nil)





Also note that the mode-line will show 'Narrow' when you're in narrow mode,
lest you forget.



When you're using org-mode there is an additional one you might want to
memorize:












what's shownnamebinding
subtreeorg-narrow-to-subtreeC-x n s




I'm using that last one quite often; I have org-files where I keep meeting notes
etc., and when in a certain meeting, I only want to see the notes for that
specific meeting.



One bug? feature? of narrowing is that line-numbering is relative to the
narrowed area rather than the full buffer. I'd prefer to have the real line
numbers.


Followers

Popular Posts