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.
Download: OmniCppComplete requires ctags.
- OmniCppComplete: GitHub Repository (To avoid mixing up of files from different plugins, use one plugin management plugin like Pathogen or Vundle.)
- Ctags: Official homepage on SourceForge (The .zip file for Win* 2**0 is fine.)
Problem: 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 Win* version of Vim Tips Wiki's tutorial, using the ideas from Carl.
Solution:
- 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.C:\ctags58 should be in the PATH variable. - Download the modified libstdc++ headers from GitHub.
- 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 Win*.
Note: In the dialogue (in case you use GUI), DON'T inputtags
at the end. Otherwise, you'll getC:\Users\[your-user-name]\.vim\tags\tags
- If things go right, you should have
C:\Users\[your-user-name]\.vim\tags
Go to that directory by typingcd .vim\tags
in Win*'s Command Prompt, which can be involked by typingcmd
in the "Start" menu. (For 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
.dir
(There're so many files that I use the/w
option to save space.) - Then you should have a huge list of ctags with the file name cpp. Not adding the additional tags for OpenGL, etc, is OK.
- 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
The folder for different plugins are separated (except the plugin management plugin itself). |
Typing :h omnicppcomplete gives you the corresponding help file. |
The contents are in the right place, so we may proceed. |
Get a list of ctags. |
>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
Testing
A picture can illustrate the feature well. Typingstd::
, 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> |
Still wrong position of the input |
Right position |
clang-dev
as well. For Win*, maybe you need to download the source. (I hope there will be a compiled version of the compiler.)Reference:
[1]: http://hi.baidu.com/dt_zhangwei/item/277572044909fc103a53eea5
No comments:
Post a Comment