Ⅰ. 插件描述
List occurrences in the current buffer in the quickfix window.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin '/grephere'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle '/grephere'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug '/grephere'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-scripts/GrepHere
Ⅳ. 文档说明
DESCRIPTION
This plugin defines a command and mappings to quickly list all occurrences of
the last search pattern, passed pattern, current word or selection in the
quickfix list. This is useful to get a somewhat persistent list of matches
that act like bookmarks, so you can recall them later (when your search
pattern has changed).
HOW IT WORKS
The plugin uses :vimgrep over the current buffer.
SOURCE
Inspired by vimtip #483: Using GREP for a "list occurrences" and quickfix help
command.
http://vim.wikia.com/wiki/Search_using_quickfix_to_list_occurrences
command GREP :execute 'grep '.expand('<cword>') expand('%') | :copen | cc
SEE ALSO
- The GrepCommands plugin (vimscript #4173) provides additional grep commands
covering arguments, buffers, windows and tab pages. - The FindOccurrence plugin (vimscript #0000) can also show all occurrences of
the <cword>, last search pattern, etc., but instead of the quickfix list,
the result is either jumped to or listed.
- The SearchPosition plugin (vimscript #2634) shows the relation of the cursor
position to the other matches of the search pattern, and provides similar
mappings. Like the quickfix list, it can provide an orientation of where and
how many matches there are.
RELATED WORKS
- outline (vimscript #1947) creates a custom view of the file based on regex,
in a scratch buffer - ttoc (vimscript #2014) is based on outline and creates a regexp-based table
of contents of the current buffer
USAGE
:[range]GrepHere [{pattern}]
:[range]GrepHere /{pattern}/g
:[range]GrepHereAdd [{pattern}]
:[range]GrepHereAdd /{pattern}/g
Grep the passed pattern (or last search pattern if
omitted) in (line in [range] of) the current file (or
the current entry of the quickfix list).
<A-N> Grep the last search pattern in the current file
and show matching lines in the quickfix window (but
don't go there).
This is similar to [N defined by
FindOccurrence.vim, but uses the quickfix list
instead of just printing all matching lines.
<A-M> Grep the current whole word under the cursor in the
current file and show matching lines in the quickfix
window (but don't go there).
This is similar to [I defined by
FindOccurrence.vim, but uses the quickfix list
instead of just printing all matching lines.
g<A-M> Grep the current word under the cursor in the current
file and show matching lines in the quickfix window
(but don't go there).
Only whole keywords are searched for, like with the
star command.
{Visual}<A-M> Grep the selected text in the current file and show
matching lines in the quickfix window (but don't go
there).
Imagine 'M' stood for "more occurrences".
These mappings reuse the last used <cword> when issued
on a blank line.