views:

393

answers:

4

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?

+4  A: 

Try this script, which uses matchadd().

George V. Reilly
+1  A: 

MultipleSearch2 is another script which is integrated with vim's search: http://www.vim.org/scripts/script.php?script_id=1183

A: 

MultipleSearch : Highlight multiple searches at the same time, each with a different color.

http://www.vim.org/scripts/script.php?script_id=479

:Search //will highlight all occurences of in the current buffer. A subsequent :Search will highlight all occurences of in the current buffer.

Naga Kiran
+1  A: 

This can be done manually, without any script, for two search patterns.

:match Search /pattern/
:match Search /<CTRL-R>/   # highlight the current search pattern

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.

:match none      # clear the match pattern to stop highlighting
philippe