1. 程式人生 > >vim中的殺手級外掛: vundle

vim中的殺手級外掛: vundle

相比sublime text2等現代編輯器,Vim缺乏預設的外掛管理器,所有外掛的檔案都散佈在~/.vim下的幾個資料夾中,配置vim的過程, 就是在網上不停的搜外掛,拷貝到~/.vim下,發現更新,要重新下載重新拷貝,想要刪除某個不需要外掛,更是要小心翼翼的不要刪錯。配置出順手的Vim, 需要極大的耐心和運氣。

當然vim社群的活力是不容懷疑的,沒有槍沒有炮大神們自己造。以前使用過tpope的pathogen,使用git submodule和pathogen, 管理外掛已經大大簡化。而今天介紹的vundle, 更是把git操作整合進去,使用者需要做的只是去Github上找到自己想要的外掛的名字,安裝,更新和解除安裝都可有vundle來完成了。雖然去發現一個好的外掛仍然是一個上下求索的過程,但是使用者已經可以從安裝配置的繁瑣過程解脫了。
Vundle的具體介紹檢視

vim.org,或者github repo

安裝和配置

下載vundle

1
 $ git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

在.vimrc 中新增bundle的配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
set nocompatible                " be iMproved
filetype off                    "
required! set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " let Vundle manage Vundle Bundle 'gmarik/vundle' "my Bundle here: " " original repos on github Bundle 'kien/ctrlp.vim' Bundle 'sukima/xmledit' Bundle 'sjl/gundo.vim' Bundle 'jiangmiao/auto-pairs' Bundle 'klen/python-mode' Bundle 'Valloric/ListToggle'
Bundle 'SirVer/ultisnips' Bundle 'Valloric/YouCompleteMe' Bundle 'scrooloose/syntastic' Bundle 't9md/vim-quickhl' " Bundle 'Lokaltog/vim-powerline' Bundle 'scrooloose/nerdcommenter' ".................................. " vim-scripts repos Bundle 'YankRing.vim' Bundle 'vcscommand.vim' Bundle 'ShowPairs' Bundle 'SudoEdit.vim' Bundle 'EasyGrep' Bundle 'VOoM' Bundle 'VimIM' ".................................. " non github repos " Bundle 'git://git.wincent.com/command-t.git' "...................................... filetype plugin indent on

bundle分為三類:

  1. 在Github vim-scripts 使用者下的repos,只需要寫出repos名稱
  2. 在Github其他使用者下的repos, 需要寫出“使用者名稱/repos名”
  3. 不在Github上的外掛,需要寫出git全路徑

安裝外掛

開啟一個vim, 執行:BundleInstall

或者在命令列執行 vim +BundleInstall +qall

安裝完成後外掛就能用了

其它常用命令:

  • 更新外掛:BundleUpdate
  • 清除不再使用的外掛:BundleClean,
  • 列出所有外掛:BundleList
  • 查詢外掛:BundleSearch