Saturday, June 21, 2008

Vim C++ Autocompletion

Download and install vimcppomnicomplete:

Install ctags (not the Emacs version):

In /usr/include type:

ctags -f ~/.vim/stdtags -R --c++-kinds=+p --fields=+iaS --extra=+q .

Add the following to ~/.vimrc:

set nocp
filetype plugin on
map <C-L> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR>

set tags=~/.vim/stdtags,tags,.tags,../tags

autocmd InsertLeave * if pumvisible() == 0|pclose|endif

The final line closes the completion box when you leave insert mode. Ctrl-L will update the tags (and so let you autocomplete based on new files) files in the current directory. Thanks go to the various places on the interwebs I robs this info from.

No comments: