它的使用方法很簡單,安裝一個插件只須要在 ~/.vimrc 按照規則中添加 Plugin 的名稱,某些須要添加路徑,以後在 Vim 中使用:PluginInstall既能夠自動化安裝。python
一、先新建目錄git
mkdir ~/.vim/bundle/Vundle.vim
二、git 克隆 Vundle 工程到本地github
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
三、修改 ~/.vimrc 配置 Plugins。在 ~/.vimrc 文件中添加以下內容並保存vim
set nocompatible " be iMproved, required filetype off " required " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins "call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required Plugin 'VundleVim/Vundle.vim' " The following are examples of different formats supported. " Keep Plugin commands between vundle#begin/end. " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required " To ignore plugin indent changes, instead use: "filetype plugin on " " Brief help " :PluginList - lists configured plugins " :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate " :PluginSearch foo - searches for foo; append `!` to refresh local cache " :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal " " see :h vundle for more details or wiki for FAQ " Put your non-Plugin stuff after this line
四、進入 vim
運行命令緩存
:PluginInstall
# 安裝插件 :BundleInstall # 更新插件 :BundleUpdate # 清除不須要的插件 :BundleClean # 列出當前的插件 :BundleList # 搜索插件 :BundleSearch
插件配置不要在 call vundle#end()
以前,否則插件沒法生效
若是配置錯誤,須要從新配置後,在vim中運行命令 :PluginInstall
app
在 ~/.vimrc 中添加以下內容 位置在call vundle#begin()
和call vundle#end()
之間ide
Bundle 'Valloric/YouCompleteMe'
在vim中運行如下命令就會自行安裝,安裝時間有點長,請耐心等待ui
:BundleInstall
編譯過程須要CMake,沒有安裝CMake可以使用如下命令進行安裝this
sudo apt install cmake
而後切換到如下目錄spa
cd ~/.vim/bundle/YouCompleteMe
最後輸入如下命令便可(默認支持python)
./install.sh
在 ~/.vimrc 中添加配置
" 自動補全配置 set completeopt=longest,menu "讓Vim的補全菜單行爲與通常IDE一致(參考VimTip1228) autocmd InsertLeave * if pumvisible() == 0|pclose|endif "離開插入模式後自動關閉預覽窗口 inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" "回車即選中當前項 "上下左右鍵的行爲 會顯示其餘信息 inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>" inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>" inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>" inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>" "youcompleteme 默認tab s-tab 和自動補全衝突 "let g:ycm_key_list_select_completion=['<c-n>'] let g:ycm_key_list_select_completion = ['<Down>'] "let g:ycm_key_list_previous_completion=['<c-p>'] let g:ycm_key_list_previous_completion = ['<Up>'] let g:ycm_confirm_extra_conf=0 "關閉加載.ycm_extra_conf.py提示 let g:ycm_collect_identifiers_from_tags_files=1 " 開啓 YCM 基於標籤引擎 let g:ycm_min_num_of_chars_for_completion=2 " 從第2個鍵入字符就開始羅列匹配項 let g:ycm_cache_omnifunc=0 " 禁止緩存匹配項,每次都從新生成匹配項 let g:ycm_seed_identifiers_with_syntax=1 " 語法關鍵字補全 nnoremap <F5> :YcmForceCompileAndDiagnostics<CR> "force recomile with syntastic "nnoremap <leader>lo :lopen<CR> "open locationlist "nnoremap <leader>lc :lclose<CR> "close locationlist inoremap <leader><leader> <C-x><C-o> "在註釋輸入中也能補全 let g:ycm_complete_in_comments = 1 "在字符串輸入中也能補全 let g:ycm_complete_in_strings = 1 "註釋和字符串中的文字也會被收入補全 let g:ycm_collect_identifiers_from_comments_and_strings = 0 nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR> " 跳轉到定義處
到此,YouCompleteMe 已安裝成功。