使用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管理的。

相關文章
相關標籤/搜索