Loading ...
Sorry, an error occurred while loading the content.

Re: Numbering a list

Expand Messages
  • Charles E Campbell Jr
    ... handle ... writing a ... What about typing one line, duplicating it p- add( ac , 0 ); p- add( ac , 0 ); p- add( ac , 0 ); p- add( ac , 0 ); and
    Message 1 of 5 , Aug 28, 2007
      On Tue 28-Aug-07 8:32am -0600, Dolazy wrote:
      >Following question is a challenge I think. I am curious if Vim could
      >Suppose I have to type following code:
      > p->>add( "ac", 0 );
      > p->>add( "ac", 1 );
      > p->>add( "ac", 2 );
      > p->>add( "ac", 3 );
      >With Vim I would only have to type the first line and then command 'yy3p',
      >and then manually change the numbers. Now I wonder if Vim could somehow
      >automatically update the numbers? I don't mind if it would require
      writing a
      >little script.

      What about typing one line, duplicating it
      p->>add( "ac", 0 );
      p->>add( "ac", 0 );
      p->>add( "ac", 0 );
      p->>add( "ac", 0 );

      and then using visual-block mode (ctrl-v, move) to highlight the zeros,
      then :I .
      You can get that type of incremented list and more: decrementing, date
      octal, roman numerals, etc.

      To do that: get visincr.vim, available from:

      (cutting edge)
      http://vim.sourceforge.net/scripts/script.php?script_id=670 (stable)

      Quick overview:
      :I [#] left justified incremented list
      :II [# [zfill]] right justified incremented list
      :IO [#] left justified octal incremented list
      :IIO [# [zfill]] right justified octal incremented list
      :IX [#] left justified hex. incremented lsit
      :IIX [# [zfill]] right justified hex. incremented lsit
      :IYMD [# [zfill]] year/month/day incremented list
      :IMDY [# [zfill]] month/day/year incremented list
      :IDMY [# [zfill]] day/month/year incremented list
      :IA [#] alphameric incremented list
      :ID [#] dayname incremented list
      :IM [#] monthname incremented list

      Chip Campbell

      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    Your message has been successfully submitted and would be delivered to recipients shortly.