安装 Vundle
由于 vim 缺乏默认的插件管理器,所有插件的文件都散布在 ~/.vim 下的几个文件夹中,这样导致各种插件的安装、更新、删除都需要自己手动处理,既麻烦费事,又可能出现错误。所以我们需要插件管理器的帮忙,常见的插件管理器有 vundle、pathogen 等等,我们这里使用 vundle。
Vundle 托管在 Github 上,所以使用 git 下载 vundle ,并将其存放于 ~/.vim/bundle/vundle 即可。使用如下命令直接将源代码检出到该目录:
$ git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
- 1
下载完了 vundle 后,还需要配置 .vimrc 文件。
为了不让 .vimrc 看起来太臃肿,我是新建了一个 ~/.vimrc.bundles 文件来保存所有插件的配置。先在 ~/.vimrc.bundles 文件中包含如下内容:
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
- 1
- 2
- 3
然后在 ~/.vimrc 文件中加入内容:
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
- 1
- 2
- 3
这样 vundle 就准备就绪了。
安装插件
我们需要知道,Bundle 分为三类:
- 在 Github vim-scripts 用户下的 repos,只需要写出 repos 名称
- 在 Github 其他用户下的 repos,需要写出“用户名/repos名”
- 不在 Github 上的插件,需要写出 git 全路径
比较常用就是第二种,也就是以“用户名/repos名”的方式。我们这里将插件的配置信息放在 ~/.vimrc.bundles,如下:
" Define bundles via Github repos " Bundle 'christoomey/vim-run-interactive' Bundle 'Valloric/YouCompleteMe' Bundle 'croaky/vim-colors-github' Bundle 'danro/rename.vim' Bundle 'majutsushi/tagbar' Bundle 'kchmck/vim-coffee-script' Bundle 'kien/ctrlp.vim' Bundle 'pbrisbin/vim-mkdir' Bundle 'scrooloose/syntastic' Bundle 'slim-template/vim-slim' Bundle 'thoughtbot/vim-rspec' Bundle 'tpope/vim-bundler' Bundle 'tpope/vim-endwise' Bundle 'tpope/vim-fugitive' Bundle 'tpope/vim-rails' Bundle 'tpope/vim-surround' Bundle 'vim-ruby/vim-ruby' Bundle 'vim-scripts/ctags.vim' Bundle 'vim-scripts/matchit.zip' Bundle 'vim-scripts/tComment' Bundle 'mattn/emmet-vim' Bundle 'scrooloose/nerdtree' Bundle 'Lokaltog/vim-powerline' Bundle 'godlygeek/tabular' Bundle 'msanders/snipmate.vim' Bundle 'jelera/vim-javascript-syntax' Bundle 'altercation/vim-colors-solarized' Bundle 'othree/html5.vim' Bundle 'xsbeats/vim-blade' Bundle 'Raimondi/delimitMate' Bundle 'groenewege/vim-less' Bundle 'evanmiller/nginx-vim-syntax' Bundle 'Lokaltog/vim-easymotion' Bundle 'tomasr/molokai' Bundle 'klen/python-mode'
- 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
接着,打开 vim,输入
:BundleInstall
或者直接在终端输入vim +BundleInstall +qall
安装插件。- 有些插件比较大,需要等待一段时间才能下载、安装完毕。