Ⅰ. 插件描述
Run vimgrep on buffersⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin '/vimgrepbuffer'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle '/vimgrepbuffer'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug '/vimgrepbuffer'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-scripts/VimgrepBuffer
Ⅳ. 文档说明
This plugin has been superceded by Buffersaurus, available at:
http://www.vim.org/scripts/script.php?script_id=3620
This plugin provides easy application of the 'vimgrep' command on buffers
(as opposed to the filesystem, which is its normal mode of operation).
It provides two commands: one to search just the current buffer, and the
other to search all listed buffers.
The QuickFix buffer will be populated with the search results, if any, and
opened for viewing. The search pattern will also be assigned to the search
register, so that matches will be highlighted if 'hlsearch' is on (':set
hlsearch').
Two commands are provided, ':G' and ':GG'. The first limits the search to
the current buffer, while the second searches all listed buffers.
If you do not like the cryptic/genericness of these 'short' commands, put:
let g:vimgrepbuffer_long_command = 1
in your "~/.vimrc", and ':VimgrepBuffer' and ':VimgrepBuffers' will be set as
the commands instead.
The pattern specification is exactly like that for 'vimgrep'. This means
that if the pattern starts with a non-identifier character or contains any literal whitespace
characters, for correct behavior you will have to enclose the pattern in
delimiter characters (e.g. "/", "@", "#"):
:G /s*print "d/
:GG /s*defs+w+(/
:G /(defs+|classs+)/
:GG /cisland/
:G /the quick brown w+/
:GG /except +w+Error/
If your pattern starts with an identifier-character you can omit the enclosing
delimiters:
:G defs+w+(.***kwargs)
:GG excepts+w+Error
In this latter case, the pattern will be considered to be
whitespace-delimited, and so if your pattern contains any literal whitespace
you may get incorrect results. This behavior is exactly like that of
'vimgrep'.
You might also be interested in looking at "grep.vim" (http://www.vim.org/scripts/script.php?script_id=311) as an alternative for "grep-on-buffer" operations, especially if you want to use external grep programs.
"grep.vim" provides a much broader range of functionality and commands, and is typically faster. However, the grep dialect you will have to use is that of the external grep programs, rather than that of Vim. The main reason I wrote "VimgrepBuffer" (and why you might be interested in using it) is to be able to use Vim's grep dialect to express the search patterns.