Reputation: 1397
Let's say I want to initialize this tuple:
t = (
#(id, name)
(1, 'aasd'),
(2, 'bsfd'),
(3, 'asf'),
...
(21, 'aefae'),
)
I am sure I can do as follow with vim.
1/ Type this:
t = (
#(id, name)
(, 'aasd'),
(, 'bsfd'),
(, 'asf'),
...
(, 'aefae'),
)
2/ Visual select comma row, and type a tricky key sequence which would write successive number
Does anyone know what is the tricky key sequence I should type?
Upvotes: 7
Views: 3080
Reputation: 8248
Instead of using VisIncr newer vims (starting with Version 8) support incrementing in visual mode. So I would go with:
Upvotes: 21
Reputation: 3086
Using the VisIncr plugin:
1
s1
s:I
- this should change the column of 1
s into numbers 1
... 21
.Upvotes: 2
Reputation: 172520
This can be solved with a macro
3Gf1
qq
lyT
, go one down j
, paste P
, increment ^A
(Ctrl+ A), stop recording q
.20@q
All together: 3Gf1lyT(jP^Aq20@q
To avoid the counting, and apply the increment until there are no more lines, you can also turn this into a recursive macro:
3Gf1
q
and start recording: qqqqq
lyT
, go one down j
, paste P
, increment ^A
(Ctrl+ A), re-invoke macro @q
. All together: lyT(jP^A@q
Upvotes: 4