I use Vim as my main IDE for C/C++ related development (as well as for almost all other development). If you use (or thinking about using) vim as as an IDE, you better get some good autocompletion functionality. This kind of autocompletion is provided by the OmniComplete, which is available since Vim 7.0. Just having the OmniComplete is a nice thing, but it’s much more helpful if configured properly to work with the libraries you use, such as wxWidgets. In this post I will show you how to get working the OmniComplete for wxWidgets, however, the procedure I will show can be easily adapted to almost all libraries.
The first step is to install
ctags (if you haven’t got it already installed), this provides the tags file, on which the autocompletion is based.
ctags is available directly from the package manager of all popular distro’s.
The next step is to install the OmniCppComplete plugin for vim. The plugin uses the
ctags‘ generated tags file for the autocompletion. In order for the autocompletion to properly work with classes, you need to create the
~/.ctags file and add some default options. Each option should be listed in a newline. Your
~/.ctags file should look like this:
--c++-kinds=+p --fields=+iaS --extra=+q
These options will now be used as default when running
The next step is to create a tag file for the wxWidgets library. This can be done using the following command:
ctags -f ~/.vim/wxwidgetstags -R /usr/include/wx-2.8
Don’t forget to replace
/usr/include/wx-2.8 with the path to the header files of wxWidgets. This will create the tags file under your
The next step is to tell vim to use this tags file. This is done by adding the following line to your
And now your done. OmniComplete will now work for wxWidgets, listing members and functions for any of the wxWidgets classes.
Remember you can repeat the last two steps for any other libraries you use in order for the OmniComplete to work with them too.
N.B. don’t forget to run
ctags -R . in your projects root dir if you want OmniComplete to work for classes you defined.