It is possible, but you'll have to do it after the syntax highlighting has been defined (most syntax highlighters start with :syn clear
, which will erase what you've done). This can be done with an autocmd. Try this:
hi link tododone tDone
hi link done tDone
hi default tDone ctermfg=DarkGreen guifg=White guibg=DarkGreen
function! HighlightKeywords()
" syn keyword is faster than syn match and is
" therefore better for simple keywords. It will
" also have higher priority than matches or regions
" and should therefore always be highlighted (although
" see comments about containedin= below).
syn keyword tododone DONE
syn region done start=/\*\*DONE/ end=/\*\*/
endfunction
autocmd Syntax * call HighlightKeywords()
Note that the syn region part can't be guaranteed as there are various overlapping issues with the region highlighter that may cause you problems.
Also, as a general note, if there are regions in which you want the highlighting to appear, these will have to be explicitly listed, which may make things a bit messy: e.g.
" Allow this keyword to work in a cComment
syn keyword tododone DONE containedin=cComment
For more information, see:
:help :syn-keyword
:help :syn-region
:help :function
:help :autocmd
:help Syntax
:help :syn-containedin
:help :syn-priority