Focusing in Emacs with narrow-to-region

Table of Contents

I was several years into my Emacs usage before mis-types revealed the glory of the “narrow” and “widen” functions to me. Actually, it was one of those nightmares: “Whoa! Where’d my document go!? And why isn’t “undo” bringing it back?” When the tears subsided, I soon realized how useful these commands are. By selecting a region and narrowing it you focus your editing and attention on a portion of what might otherwise be massive files; by so doing, your search/replace commands and your commands to jump to buffer boundaries are contained in a useful area. I use this particularly with org documents that document notes for different assignments/projects; I just narrow it to whichever one I’m working on at the moment, and widen it when I’m done. Of course there’s nothing to fear when saving a narrowed document; the rest of your data is still there, untouched, and if you were to close and re-open (or execute `revert-buffer`) you would see it all. So, select a region and use: C-x+n+n narrow-to-region C-x+n+w widen

Tory Anderson avatar
Tory Anderson
Web App Engineer, Digital Humanist, Researcher, Computer Psychologist