Vim: g Ctrl+A column increment

Created on 28 Nov 2018  路  2Comments  路  Source: VSCodeVim/Vim

In Vim 8, the first number in a selection can be incremented by pressing Ctrl-A. If the selection covers several lines, the first number in the selection on each line is incremented. Alternatively, numbers in a selection covering several lines can be converted to a sequence by typing g Ctrl-A. For example, start with the following line:

my_array[0] = 0;
Then copy it using Y6p (copy the line and paste it six times). The result is:

my_array[0] = 0;
my_array[0] = 0;
my_array[0] = 0;
my_array[0] = 0;
my_array[0] = 0;
my_array[0] = 0;
my_array[0] = 0;
With the cursor on the first 0 in the first line, start a blockwise select by pressing Ctrl-V (or Ctrl-Q if you use Ctrl-V for pasting). Move the cursor down to select the first column of zeros, then press g Ctrl-A. Using Vim 8, that will give:

my_array[1] = 0;
my_array[2] = 0;
my_array[3] = 0;
my_array[4] = 0;
my_array[5] = 0;
my_array[6] = 0;
my_array[7] = 0;
Vim 7 and earlier need a script or a macro to create a sequence.

help wanted kinenhancement

Most helpful comment

vscode-progressive-increment provides this feature, and has been working for me. Adding this to the configuration makes it activate on g<C-a>:

    "vim.visualModeKeyBindingsNonRecursive": [
        {
            "before": [
                "g",
                "C-a"
            ],
            "commands": [
                "progressive.incrementBy1"
            ]
        }
    ]

All 2 comments

I have the same issue as well, any update on this?

vscode-progressive-increment provides this feature, and has been working for me. Adding this to the configuration makes it activate on g<C-a>:

    "vim.visualModeKeyBindingsNonRecursive": [
        {
            "before": [
                "g",
                "C-a"
            ],
            "commands": [
                "progressive.incrementBy1"
            ]
        }
    ]
Was this page helpful?
0 / 5 - 0 ratings

Related issues

st-schneider picture st-schneider  路  3Comments

gerardmrk picture gerardmrk  路  3Comments

edwintorok picture edwintorok  路  3Comments

waltiam picture waltiam  路  3Comments

Jimmy-Z picture Jimmy-Z  路  3Comments