I am attempting to write a syntax file for Vim.
One of the lines of code reads
syn match constant "\**\*"
while one of many other lines reads
syn keyword aiOperators up-build
The code for highlighting is the following:
hi constant gui=bold
hi aiOperators guifg=green
However, the result of the above is that only the following is highlighted:
- The asterisks of every constant, but not the characters between them.
- Characters up until the first hyphen of aiOperators.
What seems to be the issue?
The regular expression for your constant specifies a literal asterisk, zero or more times, followed by a literal asterisk. If you intend to match characters delimited by asterisks, you need something like
\*\w\+\*: a literal asterisk, followed by one or more word characters, followed by a literal asterisk.The
:syn keywordonly works for keyword characters; by default, the hyphen is not included, so the match stops there. If, for your filetype, the hyphen belongs to the set of keyword characters, useThis should not be placed into the syntax file itself, but into
~/.vim/ftplugin/myfiletype.vim. Otherwise, use:syn match.