sponsor Vim development Vim logo Vim Book Ad

VisIncr : Produce increasing/decreasing columns of numbers, dates, or daynames

 script karma  Rating 919/702, Downloaded by 14728  Comments, bugs, improvements  Vim wiki

created by
Charles Campbell
 
script type
utility
 
description
The visincr plugin facilitates making a column of increasing or decreasing
numbers, dates, or daynames.

First, select a column using visual-block (ctrl-v) and move the cursor.

Second, choose what sort of incremented list you want:

    :I [#]  Will use the first line's number as a starting point to build
            a column of increasing numbers (or decreasing numbers if the
        increment is negative).
        Default increment: 1
        Justification    : left (will pad on the right)

    :II [# [zfill]]  Will use the first line's number as a starting point
        to build a column of increasing numbers (or decreasing numbers
        if the increment is negative).
        Default increment: 1
        Justification    : right (will pad on the left)
        Zfill            : left padding will be done with the given
                           character, typically a zero.

    :IYMD [#]    year/month/day
    :IMDY [#]    month/day/year
    :IDMY [#]    day/month/year
        Will use the starting line's date to construct an increasing
        or decreasing list of dates, depending on the sign of the
        number.
        Default increment: 1 (in days)

    :ID [#] Will produce an increasing/decreasing list of daynames.  Three-letter
            daynames will be used if the first day on the first line is a three
        letter dayname; otherwise, full names will be used.

    :IO [#]
    :IIO [#] [zfill]
        Like :I and :II, except visincr creates octal numbers.

    :IR [#]
    :IIR [#] [zfill]
        Like :I and :II, except visincr uses Roman numerals.  Negative and
        zero counts are not supported for Roman numerals.

    :IX [#]
    :IIX [#] [zfill]
        Like :I and :II, except visincr creates hexadecimal numbers.

    -------------------
    EXTRA NOTES
    -------------------
    For :I :II :IO :IIO :IR :IIR :
        If the visual block is ragged on the right-hand side (as can
        easily happen when the "$" is used to select the
        right-hand-side), the block will have spaces appended to
        straighten it out.  If the string length of the count exceeds
        the visual-block, then additional spaces will be inserted as
        needed.  Leading tabs are handled by using virtual column
        calculations.

    For :IR and :IIR :
        Since Roman numerals vary considerably in their lengths for
        nearby numbers, an additional two spaces will be included.

    For :IYMD, :IMDY, and IDMY:
        You'll need the <calutil.vim> plugin, available as
        "Calendar Utilities" under the following url:

        http://mysite.verizon.net/astronaut/vim/index.html#CALUTIL

Help is included, too -- check out  :he visincr-examples to see
even more examples of each command in action.

Examples:

        :I
                    Use ctrl-V to
        Original    Select, :I
           8            8
           8            9
           8            10
           8            11
           8            12

        :I -1
                    Use ctrl-V to
        Original    Select, :I -1
           8            8
           8            7
           8            6
           8            5
           8            4


        :II
                    Use ctrl-V to
        Original    Select, :II
           8             8
           8             9
           8            10
           8            11
           8            12

        :II -1
                    Use ctrl-V to
        Original    Select, :II -1
           8            8
           8            7
           8            6
           8            5
           8            4


        :IMDY
                  Use ctrl-V to
        Original  Select, :IMDY
        06/10/03     6/10/03
        06/10/03     6/11/03
        06/10/03     6/12/03
        06/10/03     6/13/03
        06/10/03     6/14/03


        :IYMD
                  Use ctrl-V to
        Original  Select, :IYMD
        03/06/10    03/06/10
        03/06/10    03/06/11
        03/06/10    03/06/12
        03/06/10    03/06/13
        03/06/10    03/06/14




        :IDMY
                  Use ctrl-V to
        Original  Select, :IDMY
        10/06/03    10/06/03
        10/06/03    11/06/03
        10/06/03    12/06/03
        10/06/03    13/06/03
        10/06/03    14/06/03


        :ID
                  Use ctrl-V to
        Original  Select, :ID
          Sun       Sun
          Sun       Mon
          Sun       Tue
          Sun       Wed
          Sun       Thu


        :ID
                  Use ctrl-V to
        Original  Select, :ID
         Sunday     Sunday
         Sunday     Monday
         Sunday     Tuesday
         Sunday     Wednesday
         Sunday     Thursday

        :IA
                  Use ctrl-V to
        Original  Select, :IA
           a          a
           a          b
           a          c
           a          d
           a          e

        :IO
                  Use ctrl-V to
        Original  Select, :IO
            5         5
            5         6
            5         7
            5         10
            5         11

        :IR
                  Use ctrl-V to
        Original  Select, :IR
           II         II
           II         III
           II         IV
           II         V
           II         VI

                  Use ctrl-V to
        Original  Select, :IX
            8         8
            8         9
            8         a
            8         b
            8         c


-------------
SEE ALSO
-------------
vis     : vimscript#1195 : apply any ex command (ex. :s/../../) to a visual block
vissort : vimtip#588     : how to sort a visual block (or sort based on one)
visincr : http://www.drchip.org/astronaut/vim/index.html#VISINCR (for the latest, albeit experimental, release)
 
install details
1. You need vimball v18 or later (vimscript#1502).  Please remove any vestiges of an older vimball first.
    (if you have vim 7.1 or later, you can skip this step)
2. vim visincr.vba.gz
    :so %
    :q
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
visincr.vba.gz 20 2011-08-16 7.3 Charles Campbell new     : IB and IIB support binary dec/incrementing; restricted incrementing support for :RIB, :RIIB, :RIO, :RIX, and :RIIX (ie. for binary, octal, and hexadecimal dec/incrementing); and optional long-command names.

bugfixes: two-argument IIO, IIX commands; when selection with exclusive is used.
visincr.vba.gz 19 2007-12-19 7.0 Charles Campbell Forgot to include calutil with visincr (its there now!)
visincr.vba.gz 18 2007-12-19 7.0 Charles Campbell * Power based incrementing: IPOW (2,4,8,16,...)
* Date dividers are no longer required
* Calutil is included, and they use vim 7's autoload feature (load only on demand)
visincr.vba.gz 17 2006-09-19 7.0 Charles Campbell (NEW) Visincr's commands now support expression-style completion.
(NEW) g:visincr_datedivset support included: date dividers are (default) assumed to from the set [-./]; the separator actually used is the first one found in your date column.
visincr.vba.gz 16 2006-07-25 6.0 Charles Campbell Roman numerals (:IR and :IIR) supported!
:IX, :IIX, :IO, and :IIO now support negative increments and negative counts.
visincr.vba.gz 14 2006-06-12 7.0 Charles Campbell Visincr now supports :IX, :IIX, :IO, and :IIO for creating hexadecimal and octal incremented lists, supports autoloading for faster vim startup, and informs users about :help visincr-calutil when necessary.

Autoloading by itself necessitates requiring Vim version 7.0.
visincr.vim.gz 13 2006-03-20 6.0 Charles Campbell A "zfill" of "" or '' now stands for an empty zfill.
Bugfix: visincr now insures that the first character of a month or day incrementing sequence is capitalized.
Bugfix: names embedded within lines weren't being incremented correctly; fixed!
visincr.vim.gz 12 2006-03-07 6.0 Charles Campbell Zfill capability provided ( 01 02 03 ... style incrementing).  Users may now set g:visincr_dow and g:visincr_month to customize daynames and monthnames (for date incrementing).  Handles more vim option settings.
visincr.vim.bz2 11 2004-08-24 6.0 Charles Campbell g:visincr_leaddate now allows one to specify a leading character to expand single-digit days and months into two-characters
The :IM and :ID commands (increment month, increment day) now handle varying length long names
visincr.vim.bz2 9 2004-05-14 6.0 Charles Campbell Visincr now supports incrementing/decrementing
alphabetic lists:  ie. transform a column of
(a) or a) into (a) (b) (c) (or a) b) c) ).

Visincr can now increment or decrement integers,
daynames, monthnames, dates, and alphabetic lists!

(Help is automatically installed and made available using
the HelpExtractor)
visincr.vim 8 2003-10-21 6.0 Charles Campbell Now has month incrementing (:IM) and restriction-pattern commands
(:RI, :RID, :RYMD, etc) which restrict application of renumbering
only to those lines which have numbers/daynames/dates/monthnames,
as appropriate for the command.
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github