Vim : Highlight the word TODO for every filetype

2020-06-09 04:55发布

问题:

I would like to highlight the word TODO in vim, no matter what file is edited (code or normal text). It currently works for many different languages (for example, TODO is highlighted in C/Java comments by default), but I use vim for non-code text files and I would like to see the TODOs highlighted for them too.

What is the easiest way to do that ?

回答1:

Highlighting TODO for every filetype and without possibly breaking other syntax rules can be done only by using :match/matchadd():

augroup HiglightTODO
    autocmd!
    autocmd WinEnter,VimEnter * :silent! call matchadd('Todo', 'TODO', -1)
augroup END