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. |
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 3.149.229.253
|