Ⅰ. 插件描述
Easy search highlight pinning in Vim with :matchⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'jcorbin/searchmatch'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'jcorbin/searchmatch'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'jcorbin/searchmatch'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/jcorbin/vim-searchmatch
Ⅳ. 文档说明
# searchmatch.vim
Easy search highlight pinning in Vim with :match
So if you're a frequent user of Vim's hlsearch feature, you may find yourself
wishing that you could highlight multiple searches. Well Vim has support for
this in its :match command, but doesn't make that particularly easy to use.
This plugin aims to put the full power of Vim's :match feature at the user's
fingertips in the easiest way possible: as an extension of the existing search
feature that you know and love.
You just search for something, and then pin that search with one of theSearchMatchN commands or key mappings.

The screenshot above shows /match pinned to match1, /search pinned to
match2, and /highlight pinned to match3. The colorscheme is a modified
lucius.
Basic Usage
The plugin defines 4 basic commands:
Searchmatch1-- sets the current search as first matchSearchmatch2-- sets the current search as second matchSearchmatch3-- sets the current search as third matchSearchmatchReset-- clears all matches set by thesearchmatchplugin
Unless you've already defined a mapping for <leader>/, then the default
normal mappings for these commands are:
<leader>/1-- calls Searchmatch1<leader>/2-- calls Searchmatch2<leader>/3-- calls Searchmatch3<leader>/--- calls SearchmatchReset
Additionally the user can run any of the stock match commands (:match,:2match, and :3match) to turn off any of the three highlights individually.
Highlighting
The searchmatch plugin makes use of Match1, Match2, and Match3
highlighting groups for :match, :2match, and :3match respectively.
Since most colorscheme don't define these highlighting groups, default links
are setup to the standard ErrorMsg, DiffDelete, and DiffAdd groups.
The user will almost certainly want to define these highlight groups in their.vimrc and/or patch their favorite colorscheme(s) (see for example the
author's patched lucius.vim).
Stop the default mappings
If the default mapping are causing your grief, then you can set `let
g:searchmatch_nomap = 1 in your .vimrc` to prevent searchmatch from defining
any.
About 3match
So the third match is used by other plugins, such as matchparen. But the
notion of this plugin is to give the user as much direct control over as much
match highlighting as possible.
So the SearchMatch3 command will first disable the matchparen plugin if it
is loaded. Correspondingly the SearchMatchReset command will reload thematchparen plugin if SearchMatch3 unloaded it.
Installation
Typical pathogen installation:
cd ~/.vim/bundle
git clone https://github.com/jcorbin/vim-searchmatch
Otherwise just copy plugin/searchmatch.vim into ~/.vim/plugin/searchmatch.vim.
TODO
- can do better with the default highlight definitions?
- other usage patterns, like an operator-pending mapping
- fix glitch when calling
NoMatchPareninSearchMatch3
License
MIT License. Copyright (c) 2014 Joshua T Corbin.