Alex Rivera | Logout

Vim highlight a list of words

Asked 2010-11-12T08:05:08.930
27

I need to highlight a list of words in vim, preferably the words should be defined in a file. A bit like spell checking. I have been looking at http://vim.wikia.com/wiki/Highlight_multiple_words but it requires that I define each word as a new position and does not support storing the words to a file (though they are storable).

Edit
Report

1 Answer

55

You could use the :match command.

:match Todo /word1/

The first parameter of the command is the highlight-group (to see all available groups :highlight). The second parameter is a search pattern.

You can put these in any file and load it via :source.

Another way is to change the regular expression (thx @zpon):

:match Todo /word1\|word2\|word3/

If you want to highlight them differently:

:match Todo /word1/
:2match Error /word2/
:3match Title /word3/
answered 2010-11-12T08:16:42.240

Your Answer