I'm trying to set up a minimal Vim configuration, and want to highlight all instances of the words FOO
and BAR
inside all *cpp
files.
My .vimrc
:
syntax enable
source config/highlights.vim
Inside config/highlights.vim
:
augroup myHighlighting
autocmd FileType cpp highlight FooWord ctermbg=216
autocmd FileType cpp match FooWord /\/
autocmd FileType cpp highlight BarWord ctermbg=219
autocmd FileType cpp match BarWord /\/
augroup END
It looks like only the last group is highlighted -- only instances of BAR
. Now if I put the two FooWord
lines underneath the BarWord
, then only FOO
is highlighted.
Alternatively, if I create another augroup
, the same thing happens:
augroup myHighlighting
autocmd FileType cpp highlight FooWord ctermbg=216
autocmd FileType cpp match FooWord /\/
augroup END
augroup myOtherHighlighting
autocmd FileType cpp highlight BarWord ctermbg=219
autocmd FileType cpp match BarWord /\/
augroup END
Still, only BAR
is highlighted in this case. How do I fix this?