I have the following minimal .vimrc file:
" syntax enable
syntax case match
syntax keyword MyTodo TODO PENDING
syntax keyword MyTodoIP IN PROGRESS
syntax keyword MyTodoClosed CLOSED COMPLETE DONE
hi MyTodo ctermfg=yellow
hi MyTodoIP ctermfg=darkgreen
hi MyTodoClosed ctermfg=darkgray
As is, this works fine (TODO
, etc are correctly highlighted).
However, When I uncomment syntax enable
, my syntax keywords are not highlighted as I have specified.
I looked at :help syn-enable
and it says the following:
The
:syntax enable
command will keep your current color settings. This allows using:highlight
commands to set your preferred colors before or after using this command.
I also tried using
syntax match MyTodoMatch "TODO"
with hi MyTodoWatch
with the same result.
There is a similar question on stackoverflow from 2011 that seems to be having the same problem, but no solution so I'm posting here.
What am I missing here? How can I use syntax enable
with custom keywords
?
Additionally, with syntax enable
'enabled', I can source ~/.vimrc
after opening vim and the desired syntax is applied correctly.
vim --version
:VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 19 2019 12:07:03) macOS version Included patches: 1-950 Compiled by Homebrew Huge version with MacVim GUI. Features included (+) or not (-): ...
... The relevant feature seems to be included:+syntax
. There's a lot more – John Mar 10 '19 at 20:46syntax enable
somewhere else in your set up (somewhere below$HOME/.vim
)? If so, this would reset all syntax items, if syntax is already enabled (but not the highlighting). – Ralf Mar 10 '19 at 23:04