看C++代码, 缺少合适的编辑器,捣鼓vim。
-
安装Vundle, 用于插件管理
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim --depth=1
-
安装YouCompleteMe,代码补全 (注意用系统默认的python编译,不要用anaconda)
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_server_python_interpreter='/usr/bin/python' 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中生成的部分路径。