如果不使用vundle的話,進行插件的安裝,配置和管理相對會麻煩,曾經沒使用vundle的時候我經常遇到無法安裝一些vim插件。但使用vundle后你只要在文件中添加一行你的插件名再安裝就OK了。先簡單說一下vundle的使用,相信你會愛上它。
這是它的github地址:https://github.com/gmarik/vundle
1.先安裝vim
2.創建文件夾/.vim和文件/.vimrc
進入你的home目錄創建.vim文件夾和 .vimrc文件
3.安裝vundle
$ git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
4.編輯如下內容到.vimrc文件
注:在最新的vundle中,下面的配置不在有效,最新配置請參考該項目
vimrc
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
" My Bundles here:
"
" original repos on github
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
Bundle 'tpope/vim-rails.git'
" vim-scripts repos
Bundle 'L9'
Bundle 'FuzzyFinder'
" non github repos
Bundle 'git://git.wincent.com/command-t.git'
" git repos on your local machine (ie. when working on your own plugin)
Bundle 'file:///Users/gmarik/path/to/plugin'
" ...
filetype plugin indent on " required!
"
" Brief help
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..
下面針對上面的文件做一些解釋
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
" My Bundles here:
#以后你想安裝什么插件可以寫在下面
"
" original repos on github
#如果你的插件來自github,寫在下方,只要作者名/項目名就行了
Bundle 'tpope/vim-fugitive' #如這里就安裝了vim-fugitive這個插件
Bundle 'Lokaltog/vim-easymotion'
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
Bundle 'tpope/vim-rails.git'
" vim-scripts repos
#如果插件來自 vim-scripts,你直接寫插件名就行了
Bundle 'L9'
Bundle 'FuzzyFinder'
" non github repos
#如使用自己的git庫的插件,像下面這樣做
Bundle 'git://git.wincent.com/command-t.git'
" git repos on your local machine (ie. when working on your own plugin)
Bundle 'file:///Users/gmarik/path/to/plugin'
" ...
filetype plugin indent on " required!
#下面是 vundle的一些命令代會會用到
"
" Brief help
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..
#這里可以寫一些你自己的配置
下面顯示一些我暫時的配置文件
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
" My Bundles here:
"
" original repos on github
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
Bundle 'tpope/vim-rails.git'
Bundle 'scrooloose/nerdtree'
Bundle 'kien/ctrlp.vim'
Bundle 'msanders/snipmate.vim'
Bundle 'mileszs/ack.vim'
Bundle 'Shougo/neocomplcache.vim'
Bundle 'Townk/vim-autoclose'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'Lokaltog/vim-powerline'
" vim-scripts repos
Bundle 'L9'
Bundle 'FuzzyFinder'
" non github repos
Bundle 'git://git.wincent.com/command-t.git'
" git repos on your local machine (ie. when working on your own plugin)
" ...
filetype plugin indent on " required!
"
" Brief help
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..
" NERDTree config
map <F2> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
"neocomplache config
let g:neocomplcache_enable_at_startup = 1
let g:neocomplcache_force_overwrite_completefunc = 1
"other config
set nu
set mouse=a
set tabstop=2
let mapleader = ","
let g:mapleader = ","
map Y "+y
map P "+p ""
"easymotion
let g:EasyMotion_leader_key = '<Leader>'
"powerline config
set laststatus=2
set t_Co=256
set encoding=utf-8
set fillchars+=stl:\ ,stlnc:\
5.安裝你的插件
(1)保存退出當前的vim
(2)重新打開vim,輸入命令:BundleInstall
,然后就開始安裝你的插件了。
重新打開vim,在命令模式下輸入命令PluginInstall
。
6.如何移除插件
(1)編輯.vimrc文件移除的你要移除的插件行
(2)保存退出當前的vim
(3)重新打開vim,輸入命令:BundleClean
。
重打開vim,在命令模式下輸入命名PluginClean
。