ubuntu18.04安裝Vundle外掛管理器
阿新 • • 發佈:2019-01-06
下載Vundle到制定目錄
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
Vundle的配置
參考:https://github.com/VundleVim/Vundle.vim
- 第一步
將vundle下載到制定目錄:git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
我們將其下載到了我們的/usr/home目錄下。 - 編輯配置 Plugins
開啟 .vimrc檔案,將要下載的外掛寫入 call vundle#begin()和call vundle#end()之間 - 執行vim,在命令模式下執行命令:PluginInstall或者通過命令列直接安裝:vim +PluginInstall +qall來安裝配置好的外掛。
自己的配置:
set encoding=utf-8 " Vundle set nocompatible " be iMproved, required filetype on set rtp+=~/.vim/bundle/Vundle.vim " vundle 管理的外掛列表必須位於 vundle#begin() 和 vundle#end() 之間 call vundle#begin() Plugin 'VundleVim/Vundle.vim' Plugin 'altercation/vim-colors-solarized' Plugin 'tomasr/molokai' Plugin 'vim-scripts/phd' Plugin 'Lokaltog/vim-powerline' Plugin 'octol/vim-cpp-enhanced-highlight' Plugin 'nathanaelkane/vim-indent-guides' Plugin 'derekwyatt/vim-fswitch' Plugin 'kshenoy/vim-signature' Plugin 'vim-scripts/BOOKMARKS--Mark-and-Highlight-Full-Lines' Plugin 'majutsushi/tagbar' Plugin 'vim-scripts/indexer.tar.gz' Plugin 'vim-scripts/DfrankUtil' Plugin 'vim-scripts/vimprj' Plugin 'dyng/ctrlsf.vim' Plugin 'terryma/vim-multiple-cursors' Plugin 'scrooloose/nerdcommenter' Plugin 'vim-scripts/DrawIt' Plugin 'SirVer/ultisnips' Plugin 'Valloric/YouCompleteMe' Plugin 'derekwyatt/vim-protodef' Plugin 'scrooloose/nerdtree' Plugin 'fholgado/minibufexpl.vim' Plugin 'gcmt/wildfire.vim' Plugin 'sjl/gundo.vim' Plugin 'Lokaltog/vim-easymotion' Plugin 'suan/vim-instant-markdown' Plugin 'lilydjwg/fcitx.vim' Plugin 'The-NERD-tree' " 外掛列表結束 call vundle#end() filetype plugin indent on "設定目錄樹的配置 NERDTree" autocmd vimenter * NERDTree "config show or not show Tree" map<F3>:NERDTreeMirror<CR> map<F3>:NERDTreeToggle<CR> let NERDTreeWinSize=25 let g:NERDTreeDirArrows = 1 set nu "設定行號,取消後面加! syntax on "設定高亮格式 set shiftwidth=4"shift鍵相當於幾個空格 "YouCompleteMe的配置資訊" let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py' set runtimepath+=~/.vim/bundle/YouCompleteMe let g:ycm_complete_in_comments = 1 " 在註釋輸入中也能補全 let g:ycm_seed_identifiers_with_syntax = 1 " 語法關鍵字補全 let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 註釋與字串中的內容也用於補全
以下是一些安裝外掛的例子。可以參考一下。
安裝YouCompleteMe
YouCompletMe是用來在編寫程式的時候,使得有些程式碼能夠自動補全的功能。
- 在~/.vim/vimrc中新增
Plugin ‘Valloric/YouCompleteMe’ - 執行vim,並在命令列模式中執行:
:PluginInstall - 下載完成之後,需要手動編譯後才能使用
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer
如果不需要c-famliy的補全,可以去掉–clang-completer。就這樣,安裝結束。開啟vim,如果沒有提示YCM未編譯,則說明安裝已經成功了。 - 配置YouCompleteMe
不同於很多vim外掛,YCM首先需要編譯,另外還需要配置。在vim啟動後,YCM會找尋當前路徑以及上層路徑的.ycm_extra_conf.py,需要將檔案拷貝到~/.vim/bundle/YouCompleteMe
目錄中。
配置.ycm_extra_conf.py,我把flags增加對c++相關目錄的配置,我把針對OS X的配置刪除了。
可以對其配置的話去上網查詢一下。
然後在vimrc加入該目錄: - 指定.ycm_extra_conf.py的目錄
let g:ycm_global_ycm_extra_conf = ~/.vim/bundle/YouCompleteMe/.ycm_extra_conf.py
- 配置ctags 的尋找路徑
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_seed_identifiers_with_syntax = 1
如果為1的話,會總是提示是否載入.ycm_extra_conf.py檔案
let g:ycm_confirm_extra_conf = 0
安裝Ctags
ctags的功能是可以在原始碼裡對定義的函式和巨集,以及變數進行定位,以便檢視原始的定義。在程式中對函式,巨集進行跳轉。