Vim Code Completion Status
Vim in the long history of the development, code completion has been relatively neglected areas, as compared to many IDE, vim itself of its many features include code hints completion plugin seems very simple, because vim deficiencies, it is text The compiler can not understand the program semantics. Wang Yin cited a passage:
"Text Editor" Usually this kind of thing does not really understand the programming language. Many Emacs and vi users that the use of such tools can make them etags and ctags "Go to Definition", but these tags tool is only the program "Text" do something stupid regular expression matching. They do not have a program parse, it is only after some "guessing." Simple function definition they might be able to guess the location, but for a definition of the same name, or local variables when they are insufficient.
Perhaps for python, PHP and other dynamic language, because the language itself the characteristics and rich tool support, can do a good complement effect, but for C / C ++ code completion, AutoComplPop, omnicppcomplete, neocomplcache and other plug-ins do They are "guessing."
Another reason is no big cow to do these functions. In the long history of Vim or emacs, which are in the hands of a small elite programmers to expand it requires a certain expertise, but in my generation common programmer to use it. The code completion is not large cattle must be, and I have a Swedish PSE doing Pair Programming, only use emacs or grep linux command, he can surf throughout the project, invoke the common repository clear in mind clear code structure, almost no grammar and spelling mistakes. I guess he saw the bells and whistles of vim, also used code hints, and my heart is a burst of contempt of it. So despite the large cattle coffee can make emacs, vim can be made to it, but the vim and emacs code hints always rotten three decades.
Apply after the company supports LLVM / clang born, things ushered in a turning point. clang powerful semantic analysis capabilities for C / C ++ / Object-C source-level analysis and conversion offers the possibility, began to clang-based semantic completion plugin in vim and emacs.
YouCompleteMe is a relatively new Vim code completion plugin can provide code hints based clang of C / C ++ code. It installs a simple configuration, with little Bug. For C / C ++ for youcompleteme now is the best choice, with the clang of powerful complement efficiency and high accuracy, and can be fuzzy match (see below for demo). Whatever weird wording you use C ++ code, as long as the compiler, can complement, even C ++ lambda and auto 11 are no barriers, according to the tag index complement the IDE more powerful than codeblock.
YCM installation configuration
YCM requires the latest version of Vim (7.3.584) support from the code to compile Vim way to look at this.
After using Vundle installation youcompleteme, you need to be compiled before use.
cd ~ / .vim / bundle / YouCompleteMe
Semantic complement to work properly, you need to configure .ycm_extra_conf.py file template here. You can put this file in the root directory of the project, the project file is opened, YCM will cycle up search and load the file, or adding vimrc file
let g: ycm_global_ycm_extra_conf = 'your path to .ycm_extra_conf.py'
If .ycm_extra_conf.py in other configurations include path is no problem, YCM already working.
YCM updated very frequently, and UltiSnip recent versions already integrated.
YCM has long supported integration Syntastic, the above demo which appeared before the red cross on the code is YCM combined Syntastic broke grammatical mistakes. Beginning with YCM time, pay more attention to its code completion, Syntastic did not mind, and found that the more you use the more inseparable. When writing C ++ code every time the cursor hovers over 2 seconds when, YCM will scan your current file in the background, the code you have just entered what compilation error, you can immediately show up in time to get rid of, not accumulate to the last compile time. Of course, this is a standard feature of modern IDE, vim also has a plug-in can be achieved, but with YCM later, and then install vundle Syntastic, even without any configuration to achieve these functions, it is too convenient.
YCM support code jumps, and yet another program to develop a very useful feature now supports c, cpp, object-c, object-cpp, python code branches to the declaration and implementation. Especially for c and c ++, this jump is not like those based on plug-ctags, often let you in a lot of the same name tag Azeri flesh search, ten nine do not jump in. Benefited clang of powerful, YCM code jumps almost nothing went wrong, of course, the premise is you have to set up .ycm_extra_conf.py, not too many errors when compiling code is parsed YCM.
The main function is to three YcmCompleter of subcommands:
In vim configuration file, add a line to get
nnoremap jd: YcmCompleter GoToDefinitionElseDeclaration