Vundle是一个Vim的插件管理工具,可以将需要下载和管理的插件写入一个单独文件或者.vimrc文件,轻松实现:下载、安装、升级以及插件搜索。
如果是Windows下安装Vundle,查看指导https://github.com/gmarik/Vundle.vim/wiki/Vundle-for-Windows。Linux下安装前需要git,没有则安装之。如果你的用目录下没有 ".vim/"这个目录就创建一个,在此目录下再创建 "bundle"这个文件。该目录下如果有以前的插件就删了(最好备份一下),我的是刚安装的vim,所以没那么多麻烦。
然后执行:
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
安装好后,在安装目录下的 “doc/” 文件夹下有详细的使用指导,打开之后在里面直接就可以跳到“configure”部分开始看了。按照里面的提示,将部分内容复制到~./vimrc里,要放在vimrc的开头部分,可以删去部分不需要的插件。需要复制的内容摘在如下:
set nocompatible " be iMproved, required filetype off " required " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " alternatively, pass a path where Vundle should install bundles "let path = '~/some/path/here' "call vundle#rc(path) " let Vundle manage Vundle, required Bundle 'gmarik/vundle' " The following are examples of different formats supported. " Keep bundle commands between here and filetype plugin indent on. " scripts on GitHub repos Bundle 'tpope/vim-fugitive' Bundle 'Lokaltog/vim-easymotion' Bundle 'tpope/vim-rails.git' " The sparkup vim script is in a subdirectory of this repo called vim. " Pass the path to set the runtimepath properly. Bundle 'rstacruz/sparkup', {'rtp': 'vim/'} " scripts from http://vim-scripts.org/vim/scripts.html Bundle 'L9' Bundle 'FuzzyFinder' " scripts not on GitHub Bundle 'git://git.wincent.com/command-t.git' " git repos on your local machine (i.e. when working on your own plugin) Bundle 'file:///home/gmarik/path/to/plugin' " ... filetype plugin indent on " required " To ignore plugin indent changes, instead use: "filetype plugin on " Put your stuff after this line
Bundle 'gmarik/Vundle.vim'就对应于: https://github.com/gmarik/Vundle.vim
Bundle 'ctrlp.vim'对应于: https://github.com/vim-scripts/ctrlp.vim
(3)非GitHub上的插件:则写出git全路径,如:
Bundle 'git://git.wincent.com/command-t.git'(4)本地的插件:则要写出插件的绝对路径:
Bundle 'file:///home/gmarik/path/to/plugin'
如果不喜欢将这些插件管理卸载vimrc里面,可以写个独立的文件。这是网上搜索到的方法,在vimrc里面添加:
if filereadable(expand("~/.vimrc.bundles")) source ~/.vimrc.bundles endif然后在这个 .vimrc.bundles里面写上插件管理的内容。
1)写好vimrc后,就可以安装插件了。
可以打开vim再执行:
:BundleInstall也可以直接在终端中执行:
vim +BundleInstall +qall这样,写在vimrc里面的插件就会被安装,而且自动被激活。有些插件可能需要额外的操作才可以使用,比如编译,参看该插件目录下的帮助文档就好了。如果安装出现错误,按"l"(小写的L)查看记录,查找原因。
也可以在vim里面执行:BundleInstall scriptsName.vim来安装插件,但是要下次打开vim还要加载该插件,需要将之写入vim.rc。
2)更多的操作::BundleInstall!(注意感叹号),或者
:BundleUpdate升级完成之后按 “u”查看改动记录
:BundleSearch foo这将会在http://vim-scripts.org/vim/scripts.html下搜索匹配插件
:BundleList(4)插件卸载:
:BundleClean则会删除bundle目录(“~/.vim/bundle/”,默认的目录)下的相应插件的文件。如果后加"!"则会不弹出确认删除提示。