Reputation: 445
Say I'm writing some repetitive code like:
add(x+1)
add(x+2)
add(x+3)
add(x+4)
How can I use vim's column editing to make say 1000 lines of this code with the same pattern?
Upvotes: 3
Views: 120
Reputation: 195029
type one line: add(x+1)
, then type in normal mode:
qqYp<ctrl-a>q
to record one macro. Now you can just 999@q
to have 1000 lines in this pattern.
g<c-a>
type one line: add(x+1)
, then type in normal mode:
Y999p
Now you have 1000 duplicated lines with +1)
, then:
2G<ctrl-v>}g<ctrl-a>
You got it.
Upvotes: 2