Best way to setup C++ for autocompletion in Vim?

484 views
Skip to first unread message

Richard Catlin

unread,
Oct 18, 2011, 1:07:04 PM10/18/11
to vim_use
I am new to Vim. I have always programmed in Thicker IDEs, such a
Eclipse and SlickEdit. These editors automatically setup
autocompletion for C++. What is the best way to do this in Vim? I am
on Snow Leopard.

Roger

unread,
Oct 18, 2011, 9:21:53 PM10/18/11
to vim...@googlegroups.com


My .vimrc:
" Filetype Detection
" {
"filetype on
"filetype plugin on
"filetype indent on
filetype plugin indent on "Turns all the above features on ;-)
" }

" Auto Completion (Ctrl-x Ctrl-o)
" {
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
" }

Ctrl+X + Ctrl+O performs omni-completion the lookup. (:help completion for
details.)


Install excuberant ctags:
Package name: ctags
http://ctags.sourceforge.net


Also, checkout the excellent vim plugin(s) by Fritz:

cvim - c/c++ vim plugin
http://www.vim.org/scripts/script.php?script_id=213


A good book, instead of reading VIM's help file, is "Learning the vi and Vim
Editors 7th Edition". It'll explain the vimrc settings I posted above in
detail.

--
Roger
http://rogerx.freeshell.org/

herm...@free.fr

unread,
Oct 19, 2011, 1:55:59 AM10/19/11
to vim use
Hello,

It's certainly to install clang_complete [1]. It's not that omnicppcomplete is a bad plugin, it's just that it's rely on ctags and that ctags' C++ understanding is not very good.

NB: I still require ctags in my C/C++ ftplugin suite for various advanced operations (refactoring, functions overriding, etc). Until I take the time to migrate to clang or to gcc plugins.

HTH,

[1] https://github.com/Rip-Rip/clang_complete

--
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

Ben Fritz

unread,
Oct 19, 2011, 11:13:27 AM10/19/11
to vim_use


On Oct 18, 12:07 pm, Richard Catlin <richard.m.cat...@gmail.com>
wrote:
You've got a few suggestions, already. Since you seem familiar with
Eclipse, you could also try eclim, which integrates Vim with Eclipse
(either Vim+headless Eclipse, Vim+Eclipse running separately, or Vim
running inside Eclipse):

http://eclim.org/

I haven't tried it yet myself, but it looks pretty powerful, so I do
intend to at some point.
Reply all
Reply to author
Forward
0 new messages