使用Vundle管理Vim插件

附:仓库地址
附:我自用的vim配置文件,里面注释不少,仅供参考。html

Vundle是一款Vim的插件管理软件(Linux),用起来很方便的缘由有几点:git

  • 支持插件超多,能够来源于github、Vundle自带、Vim-scripts、本地仓库等等。
  • 安装流程很是简单,配置好vimrc后一键安装/更新全部
  • Vundle很容易上手,很方便

快速使用

请先自行安装git。github

下载vundle到指定位置
$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vimvim

在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
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

最后打开vim,输入以下命令:
:PluginInstallapp

它如今正在根据vimrc中所指定的插件列表在自动下载并安装插件了,过程可能比较久,慢慢等。ui

帮助

在安装完成以后就可使用以下命令查看Vundle的一些使用方法:
:h vundlethis

经常使用命令有以下四个:
:BundleUpdate 更新插件
:BundleClean 清除再也不使用的插件
:BundleList 列出全部插件
:BundleSearch 查找插件,找到后按i便可安装spa

针对某个插件如ctrlp.vim,能够用以下命令查看该插件的信息:
:h ctrlp插件

注:

  • :PluginSearch指令所找出来的插件都在vim-scripts,这个仓库里能够找到一些插件的设置方法,文档说明等。
  • 关于vimrc应该怎么编写,请看Vundle的说明文档,或者仿照着写应该问题不大。
  • Vundle自己也是vim的一个插件,原理就是插件管理着插件而已。

离线安装插件

你可能会本身写个插件,或者因为种种缘由,没法直接使用网络方式安装,而是经过本身下载好了插件再让vundle管理,此时就须要另外的方法了。

首先是主题的安装,好比喜欢用molokai这种主题,先下载到molokai.vim这个文件,这个文件你能够去github或者其余地方找到,而后拷到本机的.vim/colors/目录下,在.vimrc中写一句Plugin 'molokai'就能够了,这和在线安装是同样的,重启下vim就生效,无需再去PluginInstall。

其次是其余插件的安装,先找到这个插件的整个文件夹,下载后放在.vim/bundle/目录下,直接整个文件夹放进去,而后在.vimrc中写一句Bundle 'xxx'就好了。举个例子,The-NERD-tree这个插件用于在vim中查看目录树,若是想要离线安装它,先从github上将仓库clone下来,丢到.vim/bundle/目录下,在.vimrc中写上Bundle 'The-NERD-tree',重启vim就生效。要注意,这样其实插件仍是让vundle管理的。

相关文章
相关标签/搜索