用 Vundle 管理 vim 插件

如果使用 pathogen 管理 vim 插件, bundle 文件夹下的 vim 插件的更新会很麻烦,你需要针对每个插件进行升级。而如果你还拥有不同的电脑,那么不同电脑上的 vim 插件如何保持一致也成问题。

 

Vundle 项目托管在github上 https://github.com/gmarik/vundle,其特色在于使用 git 来管理插件,更新方便,支持搜索,一键更新,从此只需要一个 vimrc 走天下。

 

首先,从 github 上下载 Vundle,当然,你的操作系统需要事先安装 git。

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

 

然后将下列代码加入 vimrc 中,修改配置需要要安装的 vim 插件。

set nocompatible               " 设置 vim 为不兼容 vi 模式
filetype off                   " required

set rtp+=~/.vim/bundle/vundle/
" 如果在windows下使用,设置为
" set rtp+=$HOME/.vim/bundle/vundle/
call vundle#rc()

" let Vundle manage Vundle
Bundle 'gmarik/vundle'    " required!

" My Bundles here:
"
" original repos on github
" 代码在 github 上, 使用 github 帐号/项目名
" Bundle 'tpope/vim-fugitive'
" Bundle 'Lokaltog/vim-easymotion'
" Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
" Bundle 'tpope/vim-rails.git'

" vim-scripts repos
" 代码在 vim script 上,使用插件名称,插件名字可以在 http://vim-scripts.org/vim/scripts.html 页面中查找
Bundle 'vimwiki'
Bundle 'bufexplorer.zip'
Bundle 'matrix.vim--Yang'
Bundle 'FencView.vim'
Bundle 'Conque-Shell'
Bundle 'Vimpress'
Bundle 'Markdown'
Bundle 'LaTeX-Suite-aka-Vim-LaTeX'
 
" non github reposo
" 非github的插件,使用其git地址
" Bundle 'git://git.wincent.com/command-t.git'


filetype plugin indent on    " required!
"
" Brief help
" :BundleList          - list configured bundles
" :BundleInstall(!)    - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!)      - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..

 

打开 vim,运行命令 :BundleInstall 就可以自动安装上述配置文件中的 vim 插件。

BundleInstall 是全部重新安装;BundleInstall! 是全部更新插件

如果要删除插件,则从 .vimrc 文件中删除或注释掉相应行,然后运行 :BundleClean 即可。


一般安装插件的流程为,先BundleSearch  一个插件,然后在列表中选中,按 i 安装。安装完之后,在 vimrc 中,添加Bundle 'XXX',使得bundle能够加载这个插件,如果需要配置这个插件,同样是在 vimrc 中设置。

 

之后,只要在不同电脑上同步 .vimrc 文件就可以保证不同电脑上的 vim 插件一致了。

 

bug:

BundleSearch 到的插件列表没有插件简介,当vundle 安装的插件有同名或者类似的时候,不知道哪个是哪个。

关键是同名的插件貌似选哪个都是一样的!比如 python.vim,我想要的是下面这个,但是都不是。

python.vim : Enhanced version of the python syntax highlighting script

http://www.vim.org/scripts/script.php?script_id=790

开发者的 issue 上反应有这个问题:https://github.com/gmarik/vundle/issues/183,但是没得到解决。

 

参考:

https://github.com/gmarik/vundle

http://adam8157.info/blog/2011/12/use-vundle-to-manage-vim-plugins/

http://www.zfanw.com/blog/vundle-vim-plugin-management.html

posted @ 2012-10-29 14:05  congbo  阅读(1503)  评论(0编辑  收藏  举报