sponsor Vim development Vim logo Vim Book Ad

gentypes.py : Colorize types you use while editing code (Linux)

 script karma  Rating 65/17, Downloaded by 755  Comments, bugs, improvements  Vim wiki

created by
Krzysztof Wrzalik
 
script type
utility
 
description
While browsing Vim documentation I encountered a nice tip about how to get highlithing of user-defined types. I decided to extend it a little to also support types defined elsewhere, that the source file may use (i.e. included files).

The script is written in Python and also requires CPP preprocessor (tested with 3.3 and 3.4) as well as exuberant ctags program.
 
install details
Download the script, make it executable, then put it to some directory in your PATH variable. Add the following lines to .vimrc file:

" load the types.vim highlighting file, if it exists
autocmd BufRead,BufNewFile *.{c,h,C,H,cc,hh,cpp,hpp,cxx,hxx} let fname = expand('<afile>:p:h') . '/types.vim'
autocmd BufRead,BufNewFile *.{c,h,C,H,cc,hh,cpp,hpp,cxx,hxx} if filereadable(fname)
autocmd BufRead,BufNewFile *.{c,h,C,H,cc,hh,cpp,hpp,cxx,hxx}   exe 'so ' . fname
autocmd BufRead,BufNewFile *.{c,h,C,H,cc,hh,cpp,hpp,cxx,hxx} endif

Next, cd to the directory with your source files, and invoke the script on files you would like to generate highlighting for, e.g.
gentypes.py foo.c bar.c
It should leave types.vim file in the directory. The next time you edit these files Vim should highlight types defined in them and in the files they include.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
gentypes.py 0.1.1 2005-03-08 6.0 Krzysztof Wrzalik Slightly changed to allow -I/path/to/includes, so that nonstandard locations can be used. Example usage:
gentypes.py -I/usr/include/gtk-2.0 gtk-demo.c
gentypes.py 0.1 2005-03-08 6.0 Krzysztof Wrzalik Initial upload
ip used for rating: 3.149.229.253

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github