vim下看C++代碼
阿新 • • 發佈:2017-12-05
solar ycm earch rec git clone date logs pda and
看C++代碼, 缺少合適的編輯器,搗鼓vim。
安裝Vundle, 用於插件管理
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim --depth=1
安裝YouCompleteMe,代碼補全
cd ~/.vim/bundle/ git clone https://github.com/Valloric/YouCompleteMe.git --depth=1 cd YouCompleteMe/ git submodule update --init --recursive ./install.py --clang-completer --system-libclang
修改
~/.vimrc
,增加下面一段, 管理其他插件
安裝插件命令set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'VundleVim/Vundle.vim' Plugin 'mileszs/ack.vim' Plugin 'scrooloose/nerdtree' Plugin 'tyok/nerdtree-ack' Plugin 'Xuyuanp/nerdtree-git-plugin' Plugin 'tpope/vim-rails' Plugin 'drmingdrmer/xptemplate' " Begin Snippet Plugin 'MarcWeber/vim-addon-mw-utils' Plugin 'tomtom/tlib_vim' Plugin 'garbas/vim-snipmate' Plugin 'honza/vim-snippets' Plugin 'altercation/vim-colors-solarized' " End Snippet Bundle 'Valloric/YouCompleteMe' call vundle#end() set nocompatible nmap <F2> :NERDTreeToggle<CR> let g:ycm_global_ycm_extra_conf= '~/.vim/.ycm_extra_conf.py' let g:ycm_confirm_extra_conf=0 " 基本配置 "set mouse=a syntax on set ts=4 set sw=4 set expandtab set autoindent set nu et si ai paste set ruler set hlsearch set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
:PluginInstall
使用YouCompleteMe, 安裝Bear
git clone https://github.com/rizsotto/Bear.git --depth=1 cd Bear cmake -DCMAKE_INSTALL_PREFIX=/opt/Bear . make all make install
具體使用例子
cd ~/Documents/work/gitlab/ps-sdk cp make Makefile bear make
- 生成compile_commands.json,YouCompleteMe根據它,實現代碼補全。
- 實際上發現, 還是不行。最終折中方法是使用.ycm_extra_conf.py,在BASE_FLAGS 中加入 json中生成的部分路徑。
vim下看C++代碼