上篇文章,讲述了如何配置nerdtree使得可以列出树形目录,来方便得查看当前文件夹下得文件列表。但是上篇中的方法属于手动安装配置,这节中将引入一个管理vim插件的神器-----Vundle,安装完这个插件后所有的vim的插件就可以自动下载、自动删除了。是不是觉得方便了许多呢?
Vundle
相比自己手动管理安装插件,所有插件的文件都散布在~/.vim下的几个文件夹中,配置Vim的过程, 就是在网上不停的搜插件,拷贝到~/.vim下,发现更新,要重新下载重新拷贝,想要删除某个不需要插件,更是要小心翼翼的不要删错。配置出顺手的Vim, 需要极大的耐心和运气。一般情况下的VIM插件管理方式。
Vundle(Vim bundle)是一个Vim的插件管理器。它是把git操作整合进去,用户需要做的只是去GitHub上找到自己想要的插件的名字,安装、更新和卸载都可有vundle来完成了,从此只需要一个vimrc走天下。
项目托管在 github上https://github.com/gmarik/vundle
安装
Vundle的安装需要手动安装,在安装完后别的插件的安装就可以托管给vundle了。首先从github上面下载vundle插件包。
$cd .vim & mkdir bundle //如果不存在,创建bundle文件夹
$ git clone https://github.com/VundleVim/Vundle.vim.git //下载安装包
$unzip Vundle.vim-master.zip //解压缩
$rm Vundle.vim-master.zip
然后修改.vimrc文件
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
管理插件
安装
1).vimrc中插入下面一行
Plugin 'scrooloose/nerdtree'
2)进入vim,执行:PluginInstall (Launch vim and run :PluginInstall)
或者在命令行执行:vim +PluginInstall +qall (To install from command line: vim +PluginInstall +qall)
注:Vundle分为三类:
在Github vim-scripts 用户下的repos,只需要写出repos名称
在Github其他用户下的repos, 需要写出"用户名/repos名"
不在Github上的插件,需要写出git全路径.
删除
删除Plugin行,然后执行 :PluginClean
其它常用命令:
更新插件":BundleUpdate"
清除不再使用的插件":BundleClean"
列出所有插件":BundleList"
查找插件":BundleSearch"