The introduction of the best vim plugin: OmniCppComplete : C/C++ omni-completion with ctags database

created by
Vissale NEANG

script type
ftplugin

description
This script is for vim 7.0 or higher, it provides C/C++ completion thanks to a ctags database.

If you don’t want a completion based on ctags there are solutions using compiler front ends (real C++ parsing)
- “clang” with the following script : http://www.vim.org/scripts/script.php?script_id=3302
- “gccsense” : http://cx4a.org/software/gccsense

Features :

- Complete namespaces, classes, structs and union members.
- Complete inherited members for classes and structs (single and multiple inheritance).
- Complete attribute members eg: myObject->_child->_child etc…
- Complete type returned by a function eg: myObject->get()->_child.
- Complete the “this” pointer.
- Complete a typedef.
- Complete the current scope (global and class scope).
- Complete an object after a cast (C and C++ cast).
- Complete anonymous types (eg: struct {int a; int b;}g_Var; g_Var.???). It also works for a typedef of an anonymous type.

Notes :
- The script manage cached datas for optimization.
- Ambiguous namespaces are detected and are not included in the context stack.
- The parsed code is tokenized so you can run a completion even if the current
instruction has bad indentation, spaces, comments or carriage returns between words
(even if it is not realistic).

ScreenShots :

http://vissale.neang.free.fr/Vim/OmniCppComplete/ScreenShots/screenshots.htm

install details
1) Unzip the plugin to ~/.vim (unix) or %HOMEPATH%\vimfiles (windows)
2) Run Vim and type the following command :

:helptags $HOME/.vim/doc

or

Thus to build recursively a ctags database from the current directory, the
command looks like this:

        ctags -R –c++-kinds=+p –fields=+iaS –extra=+q  .

:helptags $HOME/vimfiles/doc

3) Type :h omnicppcomplete and please read the installation paragraph.

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
omnicppcomplete-0.41.zip 0.41 2007-09-27 7.0 Vissale NEANG – It’s recommended to update ctags to version 5.7 or higher
- The plugin is now activated for C files
- New value for OmniCpp_SelectFirstItem when the option is equal to
2 the first item is selected without inserting it to
the text (patch from Marek Olszewski)
- Bug when completing union members fixed with ctags 5.7
(reported by Willem-Jan de Hoog)
- New option OmniCpp_LocalSearchDecl (patch from Roland Kuck)
- Bug when tags=something,,somethingelse (reported by Tobias Pflug)
- Bug with nested structure (reported by Mikhail Daen)
- Bug where the script fails to detect the type of a variable when
the ignorecase option is on (reported by Alexey Vakhov)
- Error message when trying to use completion on a not yet saved
Vim buffer (reported by Neil Bird)
- Error message when trying to use completion on an file opened from
a tselect command (reported by Henrique Andrade)

Top Down