I want to use syntax highlighting for custom C types. Based on my coding convention, types can occur in the following places:
typedef type1 type2;
(static | extern | register | volatile)? type ...;
(struct | enum | union) type ...;
func(type1 x, type2 x, ...); // might be a harder case
It doesn't include all the situations, but can already cover probably more than 90% of the usage. It seems to me like just a simple pattern matching problem, but I was a bit frustrated playing with vim syntax script, and couldn't get what I need. For example, I don't know how to match part of the pattern without highlighting the rest. Any ideas how to do it?
Thanks!
\zs
and\ze
are great for defining the start and end of the matching part of your patterntype name
following and preceding any number of things liketype name
. Each parameter will match that same pattern.