Professional Documents
Culture Documents
Highlighting - Is There Any Way To Highlight Multiple Searches in (G) Vim
Highlighting - Is There Any Way To Highlight Multiple Searches in (G) Vim
- Stack Overflow
I want to search for multiple strings in Vim/gVim and have them highlighted in different colours. Is
there a way of doing this with out-the-box Vim or with a plug-in?
61
vim highlighting
10 Answers
There are two simple ways to highlight multiple words in vim editor.
1. Go to search mode i.e. type '/' and then type \v followed by the words you want to search
61 separated by '|' (pipe).
Ex: /\vword1|word2|word3
2. Go to search mode and type the words you want to search separated by '\|'.
Ex: /word1\|word2\|word3
Basically the first way puts you in the regular expression mode so that you do not need to put
any extra back slashes before every pipe or other delimiters used for searching.
This is especially useful since you can still use 'n' (or 'N') to go to the next (or previous) result. – mgarey
May 25 '18 at 23:37
The only downside is that you don't get multiple colors... – Dave Dopson Jan 6 at 19:30
This can be done manually, without any script, for two search patterns.
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and
our Terms of Service.
https://stackoverflow.com/questions/704434/is-there-any-way-to-highlight-multiple-searches-in-gvim 1/4
17/01/2020 highlighting - Is there any way to highlight multiple searches in (g)Vim? - Stack Overflow
Search is the name of the highlight group, use the completion to select another group to
highlight with a different color.
:match <TAB>
:match <TAB> # completion will list all highlight group
This an be handy when you cannot use your own vim configuration.
4 Did not work for me. For anyone wondering try this: stackoverflow.com/questions/4162664/… – Eric Chen
Dec 3 '13 at 2:54
27 /search1\|search2
This works, and will highlight both search1 and search2 , but with same color. You have to do
this in vim editor.
what if you want to look for search1 but not matching search2, how can I modify that command line in
vim? – medev21 Nov 15 '17 at 16:53
:echo getmatches()
https://stackoverflow.com/questions/704434/is-there-any-way-to-highlight-multiple-searches-in-gvim 2/4
17/01/2020 highlighting - Is there any way to highlight multiple searches in (g)Vim? - Stack Overflow
:call matchdelete(7)
MultipleSearch : Highlight multiple searches at the same time, each with a different color.
http://www.vim.org/scripts/script.php?script_id=479
4
: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.
:%s /red\|green\|blue/
2 I am not sure about how to keep different colors for different keyword though. Thanks.
My Mark plugin can highlight several words in different colors simultaneously, like the built-in
search. It comes with many mappings and commands, allows to persist the patterns, and
0 supports multiple color palettes.
Does it have github page with guideline description? It is not easy to read on vim.org. Also not easy to
report issues. – Ertuğrul Altınboğa Aug 31 '15 at 5:57
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and
How can I install this plugin by Vundle? Becasue the code in github vim-scripts is too old. –
our Terms of Service
Ertuğrul. Altınboğa Aug 31 '15 at 6:18
https://stackoverflow.com/questions/704434/is-there-any-way-to-highlight-multiple-searches-in-gvim 3/4
17/01/2020 highlighting - Is there any way to highlight multiple searches in (g)Vim? - Stack Overflow
@LiMingHung That version from vim-scripts will work, but yes, it is outdated. You could ask the guys from
vim-scripts to update it; they have some annoying issues with their scraper. – Ingo Karkat Aug 31 '15 at
20:45
1 Is it possible put your plugin on github? It can install by Vundle directly. Doesn't have to rely on vim-scripts.
– Ertuğrul Altınboğa Sep 1 '15 at 3:00
I prefer highlight plugin, simple and enough, can highlight different words with differently colors
automatically.
-1 http://www.vim.org/scripts/script.php?script_id=1599
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and
our Terms of Service.
https://stackoverflow.com/questions/704434/is-there-any-way-to-highlight-multiple-searches-in-gvim 4/4