In the previous blog, I introduced how to use vim to establish a C++ development environment on Ubuntu16:
Linux Basics 12Building a C/C++ IDE with vim
This blog will introduce how to build a similar C++ development environment using vim on CentOS7. The establishment ideas of the two environments are similar, that is, to use vim's powerful plug-in extension function. The difference is that the plug-in manager used on Ubuntu is vim-addon-manager, while CentOS7 uses VBundle as the plug-in manager. The feature of VBundle is the automatic installation and update of plug-ins, which are generally stored on github.
This blog mainly refers to some of the following blogs:
https://www.cnblogs.com/hugb/p/7450845.html
https://blog.csdn.net/nzyalj/article/details/75331822
1. Install vim8.0
Download vim source code from github.
git clone https://github.com/vim/vim.git
Compile:
./configure --prefix=/opt/test/ --with-features=huge -enable-pythoninterp --with-python-config-dir=/usr/lib/python2.7/config --enable-cscope
make all doc info
There are some compilation errors when compiling the doc here, which can be ignored.
Install to the specified directory:
make install
Check the version number:
[u@11 install]$ vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 14 2018 06:54:13)
contains patch: 1-1704
[Some details omitted here]
2. Create a .vimrc file with the following contents:
1 cat .vimrc 2 set nocompatible 3 filetype off 4 5 set rtp+=~/.vim/bundle/Vundle.vim 6 call vundle#begin() 7 8 Plugin 'gmarik/Vundle.vim' 9 Plugin 'bling/vim-airline' 10 Plugin 'scrooloose/nerdtree' 11 Plugin 'kien/ctrlp.vim' 12 Plugin 'taglist.vim' 13 Plugin 'Valloric/YouCompleteMe' 14 Plugin 'winmanager' 15 Plugin 'gdbmgr' 16 17 call vundle#end() 18 19 20 filetype plugin indent on 21 22 " Brief help 23 " :PluginList - lists configured plugins 24 " :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate 25 " :PluginSearch foo - searches for foo; append `!` to refresh local cache 26 " :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal 27 " 28 29 filetype plugin indent on 30 31 let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py' 32 let g:ycm_seed_identifiers_with_syntax=1 33 let g:ycm_confirm_extra_conf=0 34 let g:ycm_cache_omnifunc=0 35 let g:ycm_min_num_of_chars_for_completion=2 36 let g:ycm_complete_in_comments=1 37 let g:ycm_complete_in_strings=1 38 39 40 set nocompatible 41 source $VIMRUNTIME/vimrc_example.vim 42 source $VIMRUNTIME/mswin.vim 43 behave mswin 44 set nobackup 45 set diffexpr=MyDiff() 46 function MyDiff() 47 let opt = '-a --binary ' 48 if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif 49 if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif 50 let arg1 = v:fname_in 51 if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif 52 let arg2 = v:fname_new 53 if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif 54 let arg3 = v:fname_out 55 if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif 56 let eq = '' 57 if $VIMRUNTIME =~ ' ' 58 if &sh =~ '\<cmd' 59 let cmd = '""' . $VIMRUNTIME . '\diff"' 60 let eq = '"' 61 else 62 let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"' 63 endif 64 else 65 let cmd = $VIMRUNTIME . '\diff' 66 endif 67 silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq 68 endfunction 69 set nu! 70 colorscheme desert 71 syntax enable 72 syntax on 73 74 set encoding=utf-8 75 set fileencodings=utf-8,chinese,latin-1 76 if has("win32") 77 set fileencoding=chinese 78 else 79 set fileencoding=utf-8 80 endif 81 source $VIMRUNTIME/delmenu.vim 82 source $VIMRUNTIME/menu.vim 83 language messages zh_CN.utf-8 84 85 86 let g:NERDTreeWinPos="left" 87 let g:NERDTreeWinSize=25 88 let g:NERDTreeShowLineNumbers=1 89 let g:neocomplcache_enable_at_startup = 1 90 91 au GUIEnter * simalt ~x 92 93 map <F2> :NERDTreeToggle <CR> 94 95 let NERDTreeShowBookmarks=1
3. Install the VBundle Plugin Manager.
Create .vim and VBundle related directories.
mkdir -p ./.vim/bundle
下载VBundle插件管理器。
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
Download and install plugins.
Mainly use the automatic download and installation function of VBundle.
Start vim 8.0.
The vim program installed by default in the system is /usr/bin/vim, and the version is 7.x. A soft link can be established in the /usr/local/bin directory. This directory is ranked at the top of the PATH environment variable. Therefore, the default vim program can be overwritten to achieve the purpose of starting vim 8.0 when vim is executed.
After starting vim, execute the following command in vim to install the plugin configured in .vimrc.
:PluginInstall
After the installation is complete vim displays Done.
4. Use the NERDTree directory tree plugin.
Press F2 to start the NERDTree directory tree plugin.