Blog 1

Random Talk on Random Thoughts

OmniCppComplete Installation for Dummies

| Comments |

Note: In a Stack Overflow question, it is suggested that clang_complete is better. For its installation, refer to its another fan’s blog.


OmniCppComplete is a great Vim plugin that has the popup menu like many big IDEs. A Youtube video can show the power of OmniCppComplete.


OmniCppComplete requires ctags.

  1. OmniCppComplete’s GitHub repository (To avoid mixing up of files from different plugins, use a plugin management plugin like pathogen.vim or Vundle.)
  2. Ctags’s official homepage on SourceForge (The ZIP file for M$ Win *2**0 is fine.)

For more detailed information on the installation of ctags, please refer to my earlier blog post Links to Good Posts.


Reading the OmniCppComplete’s documentation only, you won’t be able to understand how to use this plugin, so follow some tutorials, and the most viewed one should be on Vim Tips Wiki. Followed its guidance, I got error in typing std:: in a new CPP file. Omni completion told me something like “pattern not match”. I spent nearly 2 hours to figure out what’s wrong, and finally managed to fully understand the contents of this blog entry.

Now, I’m going to make a M$ Win* version of Vim Tips Wiki’s tutorial, using the ideas from Carl.


Step one

I suppose OmniCppComplete and ctags are installed properly.

  • OmniCppComplete does not mix up with other plugins.

    Note: For gVimPortable, do store files under the Data folder, but NOT the $VIMRUNTIME file. Otherwise the settings will be lost after upgrading gVimPortable.

    Vim plugins location using pathogen.vim

  • Typing :h omnicppcomplete in Vim normal mode gives up the help file for OmniCppComplete.

    Help for OmniCppComplete.txt

  • The folder for ctags is in the PATH environment variable.

    Follow this page for setting the PATH variable.

    Note: C:\ctags58 should be in the PATH variable.

Step two

Download the modified libstdc++ headers from GitHub.

Step three

Unzip the folder and place it under “somewhere meaningful to you”.

  • My suggestion: C:\Users\[your-user-name]\.vim
    Here you can substitute [your user name] with your real user name on M$ Win*.

  • Note: In the dialogue (in case you use GUI), don’t input tags at the end. Otherwise, you’ll get C:\Users\[your-user-name]\.vim\tags\tags

Step four

If things go right, you should have C:\Users\[your-user-name]\.vim\tags

Go to that directory by typing cd .vim\tags in M$ Win*’s Command Prompt, which can be involked by typing cmd in the “Start” menu. (For M$ Win* XP, choose “Run” and type “cmd” in the popup dialogue. If you like choosing from the menu, follow the way on the official website.)

At first, a commad prompt should be like this.

The current directory is C:\Users\Owner.

Change the current directory to C:\Users\Owner\.vim\tags.

The contents should be shown by typing dir (There’re so many files that I use the /w option to save space.)

w flag in dir command in Win* CMD
The contents are in the right place, so we may proceed.

Ctags in Win* CMD
Get a list of ctags.

To get a list of ctags, the correct command:

>ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ -f cpp .

The one you see on Vim Tips Wiki:

>ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ -f cpp cpp_src

Step five

Then you should have a huge list of ctags with the file name cpp. Not adding the additional tags for OpenGL, etc, is OK.

Step six

Finally, adding the lines found in the Vim Tips Wiki into your VIMRC will do.

Note: If you don’t add the additional tags in step 5, then the following lines should NOT be added.

set tags+=~/.vim/tags/gl
set tags+=~/.vim/tags/sdl
set tags+=~/.vim/tags/qt4


A picture can illustrate the feature well. Typing std::, you’ll get a popup list.


Incompatibility with clang_complete

Note that Omnicppcomplete is incompatible with another Vim plugin called clang_complete, due to its “unconditional popup of completion list”. To understand this, the following pictures give a good interpretation.

In OmniCppComplete, after typing std::, the completion list will pop up.

However, in clang_complete, since the information is from the clang compiler, you need to give the syntax in the right position for the compiler so as to let the completion list to show up.

missing iostream
Missing #include <iostream>

wrong place for std::

clang_complete work for correct code

On Ubuntu, it’s easy to install. Note that you need clang-dev as well. For M$ Win*, maybe you need to download the source. (I hope there will be a compiled version of the compiler.)