OmniCppComplete Installation for Dummies

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

Background

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.)

Solution

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. • Typing :h omnicppcomplete in Vim normal mode gives up the help file for OmniCppComplete. • 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.)

The contents are in the right place, so we may proceed.

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.

Testing

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 #include <iostream>

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.)