is there way add syntax coloring new types defined typedef
statements in c?
typedef struct { int a,b; } mystruct; mystruct *initmystruct(mystruct *struct, int a, int b); ^ ^ ^ ^ ^ +---------+-----------+ +------+ same color correct type color
if it's not possible natively (i guess so), there plugins make visual clue work?
i found exact solution question in vim's help, , i'm posting here in case needs in future. it's want: way read code , highlight accordingly.
syntax.txt
section 15: highlighting tags
[...] highlighting typedefs, unions , structs can done too. must use exuberant ctags (found @ http://ctags.sf.net). put these lines in makefile: # make highlight file types. requires exuberant ctags , awk types: types.vim types.vim: *.[ch] ctags --c-kinds=gstu -o- *.[ch] |\ awk 'begin{printf("syntax keyword type\t")}\ {printf("%s ", $$1)}end{print ""}' > $@ , put these lines in .vimrc: > " load types.vim highlighting file, if exists autocmd bufread,bufnewfile *.[ch] let fname = expand('<afile>:p:h') . '/types.vim' autocmd bufread,bufnewfile *.[ch] if filereadable(fname) autocmd bufread,bufnewfile *.[ch] exe 'so ' . fname autocmd bufread,bufnewfile *.[ch] endif
Comments
Post a Comment