vim 安裝YouCompleteMe 插件

原文連接:http://www.aisun.org/2017/10/vim+youcompleteme/html

 

 

要安裝YouCompleteMe ,vim須支持python。能夠命令輸入vim --version 查看, 若是python前有+號,就是支持,減號就是不支持。python

若是不支持,須要以編譯安裝方式從新安裝vim。git

編譯配置選項:github

./configure --with-features=huge --enable-pythoninterp --enable-python3interp --enable-luainterp --enable-multibyte --enable-sniff --enable-fontsetvim

 

安裝vundle插件ruby

git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundlepython2.7

在.vimrc中配置:ide

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" alternatively, pass a path where Vundle should install plugins
"let path = '~/some/path/here'
"call vundle#rc(path)

" let Vundle manage Vundle, required
Plugin 'gmarik/vundle'

" The following are examples of different formats supported.
" Keep Plugin commands between here and filetype plugin indent on.
" scripts on GitHub repos
Plugin 'tpope/vim-fugitive'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'tpope/vim-rails.git'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" scripts from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'
Plugin 'FuzzyFinder'
" scripts not on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'
" ...

filetype plugin indent on     " required
Bundle 'Valloric/YouCompleteMe'

保存退出,打開vim,輸入 :BundleInstall 進行自動安裝

+號表示已經安裝,>表示正在安裝;


在.vimrc 中添加:ui

let mapleader = ","  " 這個leader就映射爲逗號「,」this

let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'   「配置默認的ycm_extra_conf.py
nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>   「按,jd 會跳轉到定義
let g:ycm_confirm_extra_conf=0    「打開vim時再也不詢問是否加載ycm_extra_conf.py配置
let g:ycm_collect_identifiers_from_tag_files = 1 "使用ctags生成的tags文件

 

重啓vim以後出現須要更高版本的vim,須要先升級vim,

首先,要下載vim的源代碼。

cd ~

git clone https://github.com/vim/vim.git

cd vim

 進入源代碼的src目錄中,執行:
./configure --with-features=huge --enable-pythoninterp=yes --enable-cscope --enable-fontset --enable-perlinterp --enable-rubyinterp --with-python-config-dir=/usr/lib/python2.7/config --prefix=/usr/local
須要注意的是,不能寫上--enable-gui,這是開啓gui特性的,可是咱們是在終端環境下安裝的,所以不能開啓這個特性,不然會出現編譯錯誤。以後

cd ..

sudo make install

which vim

將src目錄下編譯好的vim執行文件替換上邊which vim路徑內的vim文件就升級ok了;

相關文章
相關標籤/搜索