sponsor Vim development Vim logo go to HTTPS page Vim Book Ad

narrow : Another plugin that emulates emacs' narrowing feature.

 script karma  Rating 94/40, Downloaded by 637    Comments, bugs, improvements  Vim wiki

created by
Jonas Kramer
script type
This plugin allows you to zoom into regions of a buffer by hiding everything outside the selection. Global operations like global search/replace etc. only apply to the selected region, until you widen the view again. This is useful when you have a very long function that doesn't fit the screen, and you end up in another function when searching whithout noticing (as an example). With this plugin you can zoom to that function and be sure that you keep inside it, no matter what you do.

:Narrow (takes a region, zooms to it)
:Widen (inserts the hidden parts again)

As the Narrow function actually deletes the hidden text from the buffer temporarily, this action can be undone manually by the user (using "u", ":undo", ":earlier", "g-", ...), which will break the :Widen function. For this reason, the 'u' key is remapped to a "safe" undo function. Still, there are other ways to undo the narrowing, so be careful!
Also, when in a narrowed buffer, the auto-command "BufWriteCmd" is set to a function that saves the whole file, so not only the narrowed region is saved on ".w". Don't mess with this auto-command, or you'll probably lose data!
install details
Just copy the script in your plugin folder.

The latest version can also be checked out of the Git repository at http://github.com/jkramer/vim-narrow/tree/master

Rating scripts is only available on the HTTPS page

script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
narrow.vim 0.1 2008-11-17 7.0 Jonas Kramer Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo