Reputation: 5554
I wrote a vim syntax file. I notice that all keywords except those beginning with a colon (:
) are being highlighted. Is there any way to escape colons in Vim?
Here's a section of the file:
syn keyword actionLabel :action nextgroup=actionName skipwhite
syn keyword problemLabels :goal :init :domain
syn keyword advLabels :types
syn keyword pondLabels :observe
hi def link actionLabel Statement
hi def link problemLabels Statement
hi def link advLabels Statement
hi def link pondLabels Statement
Upvotes: 2
Views: 1063
Reputation: 5554
The best solution seems to be not using the keyword
option, but using the matches
option instead.
syn match pddlLabel ':[a-zA-Z0-9]\+'
hi def link pddlLabel Statement
Upvotes: 4
Reputation: 35178
From :h :syn-define
about keywords...
It can only contain keyword characters, according to the 'iskeyword' option. It cannot contain other syntax items. It will only match with a complete word (there are no keyword characters before or after the match). The keyword "if" would match in "if(a=b)", but not in "ifdef x", because "(" is not a keyword character and "d" is.
That means you'll have to modify iskeyword for your file type to include the colon character (ascii 58). Starting from the vi default, we can support any alphabetic character, number, underscore, or colon:
set iskeyword="@,48-58,_"
Upvotes: 3