source: https://github.com/juniway/vim4cpp
This project aims to build a whole vim envoronment for cpp programming, it provides a well tuned vim settings and plugins which provide an IDE-like coding experience in vim editor.
To support full fledged vim environment, the below things are required:
- vim 7.4+ compiled with python/python3 support
- g++ (better g++4.8 or later)
- clang compiler
- cmake
- ctags
- cscope
Plugins includes:
- Vundle
- YouCompleteMe
- syntastic
- auto-pairs
- NerdTree
- vim-airline
- taglist
- cscope
- tagbar
- CtrlP
- vim-gitgutter
- vim-fugitive
- ultisnips
- vim-snippet
- Cpp11-Syntax-Support
- nerdcommenter
- powerline/fonts
- vim-colorschemes
- gundo.vim
You can simply run the script autoconf/install to install all the tools and plugins above.
$ git clone https://github.com/juniway/vim4cpp
$ cd vim4cpp
$ ./install.shThe script will install _vimrc, .ycm_extra_conf.py and other plugins in ~/.vim.
An auto command that will recoginze cpp file look like this:
au BufNewFile,BufRead *.h,*.hpp,*.inl,*.ipp,*.cpp,*.c,*.cc,*.go execute cppenv#infect()
vim4cpp provides auto complete for cpp(and other languages like c, python, etc), supported by YouCompleteMe.
Auto complete brackets:
This feature supports class, struct, union, function, lambda and C++ coroutine lambda.
The C++ coroutine lambda refers to https://github.com/yyzybb537/cpp_features
Auto complete class-methods definitions:
This feature supports all of combination class and method types below:
normal classtemplate class
and
normal methodtemplate methodstatic methodstatic template method
cppenv provides some shortcut keys for jump between c/c++ header file and c/c++ source file.
gsgnsgSgvsgvns
Use gs can jump between header and source if there were in a same folder. If the two files have the same parent folder, you can use gns to jump between there. If the two files were not in a same folder and have not the same parent folder, the gs cannot work, here, you can use gS. gS will use locate command to find the files in all of your file-system, and show the results in quickfix window when the results more than one.
gvs, gvns are as same as gs, gns nearly. Difference was the shortcut key including v will split the window vertical, and show the other file buffer on right.
If you install the complete vim environment, the _vimrc taken effect. It will give you a lot of shortcut key to boost your coding efficiency.
YouCompleteMe provides syntax complete and check.
NerdTree provides show the files tree.
TagList provides show the functions in current file.
I used ; as the vim leader charactor, so seted below:
-
;bjump to begin of line. as^ -
;ejump to end of line. as$ -
;wsave to file. as:w -
;qquit the buffer. as:quit -
;Qquit the vim. as:quitall -
;hwjump to left window. as<C-w>h -
;jwjump to under window. as<C-w>j -
;kwjump to over window. as<C-w>k -
;lwjump to right window. as<C-w>l -
;/cancel highlight. as:nohls<CR> -
;as", e.g. you can use;ayto copy selection intoaregister, and use;apto pastearegister words into cursor position. -
F3toggle theNerdTreewindow, show the files tree. -
F4static syntax check current source file.
gyjump to the word on the cursor definition or declaration. as call the YCM methodGoToDefinitionElseDeclaration.gYshow the word on the cursor definition or declaration on right window.gljump to last buffer. as:b#<CR>gLjump to last buffer and show current buffer on right window
<C-h>jump to previous tabpage. as:tabprevious<CR><C-l>jump to next tabpage. as:tabnext<CR>
F7build current file, outputout.exeF5build and run. outputout.exeF8build and run with libboost. outputout.exe
<C-j>trigge the snippet.
Support snippet trigger list below:
-
timethe output for e.g:2015-11-20 23:56:18 -
dateoutput for e.g:2015-11-20 -
namespace <name>e.g.
input:
namespace ucorfoutput:
namespace ucorf { } //namespace ucorf -
GNU License <name>Make gnu license copyright header in source file. -
def <class name>First, you must save your class definition. Then, inputdef <class name>, will output all method definitions of the class.





