我想在Vim/gVim中搜索多个字符串,并以不同的颜色突出显示它们.有没有办法用开箱即用的Vim或插件做到这一点?
Rav*_*eja 57
在vim编辑器中有两种简单的方法可以突出显示多个单词.
基本上,第一种方法是使您进入正则表达式模式,这样您就不需要在用于搜索的每个管道或其他分隔符之前添加任何额外的反斜杠.
phi*_*ant 44
对于两种搜索模式,这可以手动完成,无需任何脚本.
:match Search /pattern/
:match Search /<CTRL-R>/   # highlight the current search pattern
搜索是突出显示组的名称,使用完成选择另一个组以使用不同的颜色突出显示.
 :match <TAB>
 :match <TAB>    # completion will list all highlight group
当您无法使用自己的vim配置时,这非常方便.
:match none      # clear the match pattern to stop highlighting
Nar*_*ren 27
要在vim中搜索多个字符串,您可以这样做:
/search1\|search2
这工作,并强调双方search1和search2,但相同的颜色.你必须在vim编辑器中这样做.
MultipleSearch:同时突出显示多个搜索,每个搜索具有不同的颜色。
http://www.vim.org/scripts/script.php?script_id=479
:Search <pattern1> //will highlight all occurences of <pattern1> in the current buffer.
A subsequent :Search <pattern2> will highlight all occurences of <pattern2> in the current buffer.
是的,你可以使用开箱即用的matchadd().
要添加突出显示,例如.用于尾随空格:
:highlight ExtraWhitespace ctermbg=grey guibg=grey
:call matchadd('ExtraWhitespace', '\s\+$', 11)
要查看所有匹配项:
:echo getmatches()
要删除匹配使用matchdelete().例如.:
:call matchdelete(7)