Ⅰ. 插件描述
Vim plugin that emulates emacs' narrowing feature (but better than the other plugin that cheats and just folds the rest of the text, so it isn't really gone but still searchable and affected by global operations).Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'jkramer/narrow'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'jkramer/narrow'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'jkramer/narrow'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/jkramer/vim-narrow
Ⅳ. 文档说明
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.
Commands:
:Narrow (takes a region, zooms to it)
:Widen (inserts the hidden parts again)
Notes:
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!