Vim插件管理工具Vundle的安装与使用

来源:互联网 发布:ff14人族女捏脸数据 编辑:程序博客网 时间:2024/05/16 19:48

简介:    

       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, requiredfiletype off                  " required" set the runtime path to include Vundle and initializeset 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, requiredBundle 'gmarik/vundle'" The following are examples of different formats supported." Keep bundle commands between here and filetype plugin indent on." scripts on GitHub reposBundle '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.htmlBundle 'L9'Bundle 'FuzzyFinder'" scripts not on GitHubBundle '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

从以上的内容可以看出,Vundle管理的插件分为4类:

(1)GitHub上的非vim-scripts用户的插件,这类源要以 user/repo 的格式来写,例如:
Bundle 'gmarik/Vundle.vim'
就对应于: https://github.com/gmarik/Vundle.vim
(2)来自于GitHub上vim-scripts用户下的插件,可以不写出用户名例如:
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)更多的操作:
(1)升级插件:

:BundleInstall!
(注意感叹号),或者

:BundleUpdate
升级完成之后按 “u”查看改动记录
(2)搜索插件
:BundleSearch foo
        这将会在http://vim-scripts.org/vim/scripts.html下搜索匹配插件
(3)列出已装插件  
:BundleList
(4)插件卸载:
       在vimrc里面将要卸载的插件的 Bundle那一行删除掉,然后执行
 :BundleClean
 则会删除bundle目录(“~/.vim/bundle/”,默认的目录)下的相应插件的文件。如果后加"!"则会不弹出确认删除提示。

        更多关于Vundle的详细内容,可以看插件Vundle的安装目录里的 doc/ 目录下的vundle.txt,或者GitHub上的Vundle的主页,以上内容都在这两个地方详细描述。        
0 0