Syntax highlighting works swimmingly beautiful with the standard types, like int
, uint32_t
, float
and so on. However, I would like to teach vim that there are other types defined with typedef in my code, e.g.
typedef double float64_t;
How can I make vim use the same highlighting for float64_t
as for the standard types? A solution with a local file (e.g. within my ~/.vimrc
or .vim
directory) would be preferred. Automatic parsing of typedef names not a requirement, I'm willing to add typedef names as needed.
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With