increment_new.vim


Ⅰ. 插件描述

Subsitute a pattern with incremented values ENHANCED

Ⅱ. 基本信息

创建日期:  2005-02-04
使用用户:  1
Github星:  2
插件作者:  Ely Schoenfeld

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin '/increment-new-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle '/increment-new-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug '/increment-new-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/vim-scripts/increment_new.vim

Ⅳ. 文档说明

This is a great (I think) improvement of the plugin increment.vim made by William Natter (natter at magma.ca) (vimscript #842).

I tried to contact William, but his mailbox does not exist... So here it goes.

As William wrote:
"This is a handy plugin that makes easy replacing your favorite pattern ("@" by default) with a sequence of incremented values using the "Inc" command.  "

Besides what the original script can do, it has two new features:
    a) Now you are able to search for a pattern and replace the Nth word from the beginning of the line with the incremental number.
    b) And also you can get a confirmation message before change.

The help file is also greatly improved.

Here is an example:

       You have: (beginning with spaces only)
           ----- cut -----
                   LMsgInstall6 = 7; // @
                 LMsgInstall7 = 8;   // @
               LMsgInstall8 = 9;     // @

               {STANDALONE}
               LErrConnectionStandAlone1 = 10; //THIS
               LErrConnectionStandAlone3 = 7; //THIS
               LErrConnectionStandAlone5 = 12; //THIS
           {some text}
               LMsgExitConfirm = 30;
           ...
           ----- cut -----

       You do: (with confirmation)
           :'<,'>Inc p^ \<[A-Za-z0-9_]\> = [0-9]* w3 i25 s100 c
                                   (Note that I had to use tree "" before the "<" sign. Since Vim 7 the "<" and ">" have to be skiped by a "")

       You get:
           ----- cut -----
                   LMsgInstall6 = 100; // @
                 LMsgInstall7 = 125;   // @
               LMsgInstall8 = 150;     // @

               {STANDALONE}
               LErrConnectionStandAlone1 = 175; //THIS
               LErrConnectionStandAlone3 = 200; //THIS
               LErrConnectionStandAlone5 = 225; //THIS
           {some text}
               LMsgExitConfirm = 250;
           ...
           ----- cut -----

       Then you do: (without confirmation)
           :'<,'>Inc pTHIS w3 i3 s5

       You get:
           ----- cut -----
                   LMsgInstall6 = 100; // @
                 LMsgInstall7 = 125;   // @
               LMsgInstall8 = 150;     // @

               {STANDALONE}
               LErrConnectionStandAlone1 = 5; //THIS
               LErrConnectionStandAlone3 = 8; //THIS
               LErrConnectionStandAlone5 = 11; //THIS
           {some text}
               LMsgExitConfirm = 250;
           ...
           ----- cut -----

       Then you do: (without confirmation)
           :'<,'>Inc

       You get:
           ----- cut -----
                   LMsgInstall6 = 100; // 0
                 LMsgInstall7 = 125;   // 1
               LMsgInstall8 = 150;     // 2

               {STANDALONE}
               LErrConnectionStandAlone1 = 5; //THIS
               LErrConnectionStandAlone3 = 8; //THIS
               LErrConnectionStandAlone5 = 11; //THIS
           {some text}
               LMsgExitConfirm = 250;
           ...
           ----- cut -----

Hope it helps.

Keywords: Inc Increment increment increment.vimnumber numbers num replace substitute subst pattern regex

添加新评论