Emacs Narrowing: A Feature Show Off
When working with code, there are times when you want to find out if a certain variable/class name/word is being used within a function or a segment of your code. The tedious way to find out will be to start at the beginning of that segment and slowly (or not) scroll down the page with your eyes trained on the code, being careful not to miss the keyword. Not only is this time consuming, but it’s likely not very accurate. Of course, you can instead search for the keyword in the whole file, but then there’s a good chance there are a number of them, and you will have to go through each of them and find the one that’s inside the region you’re interested in. Not that fun.
With Emacs’ narrowing, this task becomes way simpler. Simply highlight the segment you want to focus on, then “narrow” the page so that the page now consists of that segment alone, and search for the keyword in question. Easy peasy.
A picture speaks louder than words:
(Assuming I am looking for the keyword “Thanks” inside the validateComments function only, this is how I can do it easily with Emacs.)
Ok, done bragging. Signing off for this post.