VIM is one of the best editors in the world. Maybe some programmers who are familiar with Visual Studio may complain that the vim can’t do the code completion like the Visual Studio does which is a very useful feature for most of us. If you thought that, then you are wrong. With the help of three party tools and plugins, you also can use this feature in the VIM.
Required Tools/Plugins
- VIM (Are you crazy? We are talking about vim, how can we do it without this friend.)
- Ctags (This is a default tool in Linux. But please check it first, I can’t remember it clearly.)
- OmniCppComplete
Downloading the OmniCppComplete and unziping it to your ~/.vim/
Do the configuration like below. I refer to this link about the configuration.
Then, you need generate tags. If you just want to generate tags for current directory, you simply press Ctrl+F12. Then you can use the tags for current directory, which means that the code completion would work for the code you write in current directory.
You are using the C++ language, you need use the STL usually. How can you remember all the functions in the STL? How can we use the tags for STL?
- First, download the STL source code from SGI
- Unzip it, and go to that directory
- find . -name ‘*.h’ | xargs sed -i ’s/__STL_BEGIN_NAMESPACE/namespace std {/’
- find . -name ‘*.h’ | xargs sed -i ’s/__STL_END_NAMESPACE/}/’
- ctags -R –c++-kinds=+p –fields=+iaS –extra=+q ./
- Then you will find there is a new file named tags, copy this file to a place you like. Name it what you like. Then add a line like it in yout .vimrc file. set tags+=your file path. You can see it from the configuration screenshot above.
No comments:
Post a Comment