sponsor Vim development Vim logo Vim Book Ad

sequence : Increment / Decrement a sequence of numbers

 script karma  Rating 10/4, Downloaded by 288    Comments, bugs, improvements  Vim wiki

created by
Dimitar Dimitrov
 
script type
utility
 
description
Usage:

Put the cursor anywhere on these lines. The range will be guessed and the first
sequence of numbers will be transformed. If you want to transform the second
sequence of numbers you must use a visual block selection (dashes in this
example).

array [1] = 9              array [1] = -9-              array [1] = 9
array [1] = 9              array [2] = -9-              array [2] = 8
array [1] = 9    alt-a:    array [3] = -9-    alt-x:    array [3] = 7
array [1] = 9              array [4] = -9-              array [4] = 6
array [1] = 9              array [5] = -9-              array [5] = 5

With a count:

array [1] = 9                array [1] = -9-                array [1] = 9
array [1] = 9                array [3] = -9-                array [3] = 7
array [1] = 9    2 alt-a:    array [5] = -9-    2 alt-x:    array [5] = 5
array [1] = 9                array [7] = -9-                array [7] = 3
array [1] = 9                array [9] = -9-                array [9] = 1

Note: If the range is not easy to guess, use a selection instead

If you wanted to increment / decrement all numbers by only one, select your
lines and press ^a / ^x

   v mode                     ^v mode
array [1] = 8             array [6] = -8-             array [6] = 5
array [1] = 8             array [6] = -8-             array [6] = 5
array [1] = 8    5 ^a:    array [6] = -8-    3 ^x:    array [6] = 5
array [1] = 8             array [6] = -8-             array [6] = 5
array [1] = 8             array [6] = -8-             array [6] = 5

----------------------------------------------------------------------------

This plugin integrates with Tim Pope's repeat plugin. It means that you can use
. to repeat any normal mode (for now) sequence mapping you just used!

For more information see: http://github.com/tpope/vim-repeat

----------------------------------------------------------------------------

You have the possibility to define your own custom mappings in your .vimrc:

    vmap <m-a> <plug>SequenceV_Increment
    vmap <m-x> <plug>SequenceV_Decrement
    nmap <m-a> <plug>SequenceN_Increment
    nmap <m-x> <plug>SequenceN_Decrement

    vmap <c-a> <plug>SequenceAdd
    vmap <c-x> <plug>SequenceSubtract

Note: You can replace Alt+a, Alt+x, Ctrl+a and Ctrl+x with whatever you like.
 
install details
sequence.vim -> ~/.vim/plugin
sequence.txt -> ~/.vim/doc

Latest version at:
https://github.com/kurkale6ka/vim-sequence
 

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
sequence.zip 2.0 2010-10-06 7.0 Dimitar Dimitrov Made the plugin mappings more flexible: you could redefine them in your .vimrc if you wanted
Added support for Tim Pope's repeat plugin in normal mode
sequence.zip 1.0 2010-09-26 7.0 Dimitar Dimitrov Initial upload
ip used for rating: 54.83.103.17

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.
   
SourceForge.net Logo