• vim-addon-manager【转】


    Vim是一个非常优秀的编辑器,但是没装插件的Vim就始终只是个编辑器而已,是插件让Vim变得更加强大。

    但是插件装得多了,管理就成了问题,Vim本身并没有提供插件管理功能,往往时间一长,.vim/vimfile 文件夹下就变得杂乱不堪。

    vim-addon-manager这个插件就是为了管理Vim插件的插件。

    介绍:

    This plugin allows users to install and uninstall plugins with a minimum of work. Features:
        - Separate directories for each plugins
        - Dependency resolution
        - Popular VCS support: plugin supports fetching from Git, Mercurial,
          Subversion and Bazaar repositories

    简单来说就是可以非常方便的安装和卸载插件。

    依赖关系:

    - Curl, wget or other program that can output URL contents to stdout (in
          order to get http protocol support)
        - Git, Mercurial, Subversion and Bazaar (if you want to install plugins
          from appropriate repositories)
        - vcs_checkouts plugin (comes with this addon)
        - Either tar, gzip and zip or 7-zip (required for unpacking some addons)
        - Vimball plugin (required for installing some addons) (in latest vim it
          is included by default)

    linux下基本上安装下git和Mercural就可以开始安装了,windows下就比较麻烦,需要自行下载Curl,7z并将路径加入系统path,并安装msysgit。

    在一切准备工作做好之后,就可以开始安装了。

    新建一个目录用于存放插件文件,如:

    1
    ~/vim-addons

    然后进入这个文件夹,并下载插件文件:

    1
    2
    cd ~/vim-addons
    git clone git://github.com/MarcWeber/vim-addon-manager.git

    安装完毕,会发现vim-addons文件夹下多了一个vim-addon-manager文件夹,这个文件夹中存放了vim-addon-manager的主要文件。

    接着在.vimrc/_vimrc文件夹下添加以下代码:

    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    fun SetupVAM()
       set runtimepath+=~/vim-addons/vim-addon-manager
       " commenting try .. endtry because trace is lost if you use it.
       " There should be no exception anyway
       " try
         call vam#ActivateAddons(['pluginA', 'pluginB'], {'auto_install' : 0})
         " pluginA could be github:YourName see vam#install#RewriteName()
       " catch /.*/
       "  echoe v:exception
       " endtry
     endf
     call SetupVAM()
     " experimental: run after gui has been started (gvim) [3]
     " option1:  au VimEnter * call SetupVAM()
     " option2:  au GUIEnter * call SetupVAM()
     " See BUGS sections below [*]

    将代码中的runtimepath后面改正本机上vim-addon-manager的路径。

    然后打开vim(linux下似乎不能直接打开图形版vim?笔者试着直接打开会无法运行,需要在终端中执行gvim打开),首次执行时会下载插件仓库文件(需要git)。

    一切完成之后,就可以开始使用了。

    安装插件:

    1
    :InstallAddons {name}

    比如需要安装taglist,就执行:

    1
    :InstallAddons taglist        #注意大小写

    这里不能不说一下,vim-addons-manager有个不太方便的地方,就是安装插件时插件的名字一定要与仓库中的完全匹配,这就给安装带来了一些麻烦。笔者的做法是自行打开

    1
    ~/vim-addons/vim-addon-manager-known-repositories/plugin/vim-addon-manager-known-repositories.vim

    并在其中查找插件的完整名称,然后进行安装。

    激活插件:

    1
    :ActivateAddons {name}

    如:

    1
    :ActivateAddons taglist

    不过要注意这样激活的插件在下次打开Vim的时候是不会自动激活的,如果希望每次打开Vim都自动激活该插件,则需要在.vimrc/_vimrc文件中修改如下语句:

    1
    call vam#ActivateAddons(['pluginA', 'pluginB'], {'auto_install' : 0})

    将其中的“pluginA”,“pluginB”修改为需要激活插件的名字(方括号内可以继续添加),下次启动Vim时就可以自动激活。

    事实上,之后同步Vim插件就非常方便了,只需要同步.vimrc/_vimrc文件和vim-addon-manager插件就行了,所有在vam#ActivateAddons中包含的插件在首次运行时会自动安装,是不是很方便呢?

    不过有些插件安装后有些问题,比如C/C++ IDE 安装后会找不到template,不过可以通过修改插件来修正。

    以上只是一些基础的用法,更详细的使用帮助可以查阅插件的帮助。

  • 相关阅读:
    Windows Azure 架构指南 – 第 1卷 发布
    SQL Azure 入门教学(一):SQL Azure之初体验
    WPC大会新动态: Windows Azure Platform Appliance发布
    Windows Azure AppFabric 入门教学(七):多播(Multicast)
    PHP on Windows Azure 入门教学系列(一):在Windows Azure内运行PHP应用
    SQL Azure SU3 现已在全球6座数据中心开始启用
    WPC大会新动态:合作伙伴采纳Windows Azure
    时间的运算
    把字符串复制到剪贴板
    常用的表格效果
  • 原文地址:https://www.cnblogs.com/wangnan1979/p/3243105.html
Copyright © 2020-2023  润新知