代码改变世界

Vim插件管理

2015-09-07 16:11  cascle  阅读(217)  评论(0编辑  收藏  举报

最新的Vim插件管理脚本是Vundle。

其将插件脚本的分布从以前的集中式改为现在的分布式(见下)

The original way:

vim/
    syntax/
        html.vim
    indent/
        html.vim

The bundle way:

vim/bundle/
    html/
        syntax/
            html.vim
        indent/
            html.vim

并且安装、卸载更方便。

可以参照https://github.com/VundleVim/Vundle.vim/blob/master/doc/vundle.txt来做(版本会有更新,以最新为准),也不多,就300多行说明

使用步骤如下

1.下载

 git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim

注意,额外话:若要对插件的增加删减做版本管理,也可以用git submodule

git submodule add  https://github.com/gmarik/Vundle.vim.git .vim/bundle/Vundle.vim

2.配置.vimrc

 1     set nocompatible              " be iMproved, required
 2     filetype off                  " required
 3 
 4     " set the runtime path to include Vundle and initialize
 5     set rtp+=~/.vim/bundle/Vundle.vim
 6     call vundle#begin()
 7     " alternatively, pass a path where Vundle should install plugins
 8     "call vundle#begin('~/some/path/here')
 9 
10     " let Vundle manage Vundle, required
11     Plugin 'gmarik/Vundle.vim'
12 
13     " The following are examples of different formats supported.
14     " Keep Plugin commands between vundle#begin/end.
15     " plugin on GitHub repo
16     Plugin 'tpope/vim-fugitive'
17     " plugin from http://vim-scripts.org/vim/scripts.html
18     Plugin 'L9'
19     " Git plugin not hosted on GitHub
20     Plugin 'git://git.wincent.com/command-t.git'
21     " git repos on your local machine (i.e. when working on your own plugin)
22     Plugin 'file:///home/gmarik/path/to/plugin'
23     " The sparkup vim script is in a subdirectory of this repo called vim.
24     " Pass the path to set the runtimepath properly.
25     Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
26     " Avoid a name conflict with L9
27     Plugin 'user/L9', {'name': 'newL9'}
28 
29     " All of your Plugins must be added before the following line
30     call vundle#end()            " required
31     filetype plugin indent on    " required
32     " To ignore plugin indent changes, instead use:
33     "filetype plugin on
34     "
35     " Brief help
36     " :PluginList          - list configured plugins
37     " :PluginInstall(!)    - install (update) plugins
38     " :PluginSearch(!) foo - search (or refresh cache first) for foo
39     " :PluginClean(!)      - confirm (or auto-approve) removal of unused plugins
40     "
41     " see :h vundle for more details or wiki for FAQ
42     " Put your non-Plugin stuff after this line
Plugin分为三类:
  1. 在Github vim-scripts 用户下的repos,只需要写出repos名称
  2. 在Github其他用户下的repos, 需要写出”用户名/repos名”
  3. 不在Github上的插件,需要写出git全路径

3. 在.vimrc中配置好了必要的语法后,也配置好了需要的插件后,就可以打开Vim用PluginInstall命令来安装插件了,当然也可以罗列、更新、搜索、删除插件

 

4.注意,.vimrc和命令模式下的相关命令改了,以前是Bundle***,现在是Plugin***