How can I teach vim about additional C language types for syntax highlighting?
Here is a way to add the names as needed.
For Windows, create (replace vimfiles
as appropriate)
~\vimfiles\after\syntax\c.vim
and add lines defining new syntax highlighting items. For example (from my cpp.vim
),
" add nullptr as a keyword for highlighting
syn keyword Constant nullptr
To determine which group you want to add to, open a c file and type :syntax
and you can look through the existing syntax groups.
I also found out that we can use the match
command to cover a set of typedef names described by a pattern:
match Type /\w*_t/
will highlight as a type all typedef names ending in _t
(but will do so everywhere, even inside comments and string literals.)