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

Re: Number Changes

Expand Messages
  • Charles E Campbell Jr
    ... If these numbers are in columns (and you did say tab-delimited, so perhaps they are), then visincr.vim may be helpful. With the visincr.vim plugin: Change
    Message 1 of 3 , Feb 27, 2007
    • 0 Attachment
      Mike Blonder wrote:

      > Hi.
      >
      > I periodically need to make changes to a script built with tab
      > delimited values. What I need to do is, from time to time, to either
      > add 1 to a value or to subtract 1 from the same value. Typically the
      > script looks like:
      >
      > ln 1 $10 !="" { printf "((moodlook " $10 }
      > ln 2 $11 !="" { printf "((feeloil " $11 }
      > ln 3 $12 !="" { printf "((eyeflavor " $12 }
      > . . .
      >
      > Is there an alternative to manually CTRL-A'ing each line twice to
      > change ln 1, for example, to
      >
      > #11 !="" { printf "((moodlook " $11 }


      If these numbers are in columns (and you did say tab-delimited, so
      perhaps they are), then visincr.vim may be helpful.
      With the visincr.vim plugin:

      Change number in upper left hand corner to what you want it to be.
      ctrl-v to begin visual block mode with the upper left hand corner of
      column of numbers
      move cursor to lower right hand corner of column
      :I

      This process will change one column of numbers. You can get visincr from:

      http://mysite.verizon.net/astronaut/vim/index.html#VISINCR
      or from
      http://vim.sourceforge.net/scripts/script.php?script_id=670

      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

      And, if your "columns" of numbers aren't aligned, but you'd like them to
      be, check out Align.vim (available at my website, too).

      Regards,
      Chip Campbell
    Your message has been successfully submitted and would be delivered to recipients shortly.