Wednesday, June 2, 2010

Gvim as a c++ IDE

The VI was / is one of the most famous text editor, and the main reason why it got an important role is the fact that it is much more than a simple editor.
Many software developer also likes it (especially it's derives vim and gvim), because it can be used as an IDE, the only thing you should do is to install additional plugins for it.

Here a list you should try if haven't done it already:
To install them, create a ~/.vim directory, copy the zip files into it, then unzip the files.
To use c.vim consider modifying in ~/.vim/c-support/templates directory a few files, like: Templates, c.comments.template and cpp.comments.template
Modify your .vimrc file for a.vim, add these lines:
" a.vim: to search e.g. .hh files, too
let g:alternateExtensions_hh = "c,cpp,cxx,cc,CC"
let g:alternateExtensions_cc = "h,hh,hpp"

The plugins above are using tags file, which can be created by ctags. Note! Do not use emacs' ctags use exuberant ctags instead (default in Slackware).
To generate tags file use this command (e.g.):
ctags --c++-kinds=+p --fields=+iaS --extra=+q -R * *.cc *.c *.hh *.h
I've added an alias in my .bashrc:
alias ctagscppr='ctags --c++-kinds=+p --fields=+iaS --extra=+q -R * *.cc *.c *.hh *.h'

To use TagList type :TlistToggle in gvim.
To use OmniCppComplete just press "." or "->". By default "::" won't do anything (If I remember well C-x o is the default trigger for this plugin.)