Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In VIM editor how can some specific words be always highlighted?

Tags:

vim

A few words such as TODO remain highlighted always in VIM.

Can I add some custom words to this list which I want to be highlighted always?

like image 629
VineetChirania Avatar asked Dec 29 '14 09:12

VineetChirania


People also ask

How do I color a word in vim?

You can change color schemes at anytime in vi by typing colorscheme followed by a space and the name of the color scheme. For more color schemes, you can browse this library on the vim website. You can enable or disable colors by simply typing "syntax on" or "syntax off" in vi.


1 Answers

Todo is a syntax group, :h group-name to check detail.

If you want to make some words/text highlighted, you can either edit syntax file, or create your own hi-groups (:h highlight-groups) and add match.

For example:

You can do match todo /!Important!/ to let text !Important! to be highlighted in same way as TODO. Or:

hi! Important ctermbg=red guibg=red

this will create a hi-group called Important.

Then you add match:

:match Important /!Important!/

this will highlight text !Important! in the way you defined in the group.

You could also add those lines in your vimrc.

like image 165
Kent Avatar answered Sep 23 '22 15:09

Kent