Navigate up to firstName
in Normal mode and type
qaIprivate readonly string <ESC>jq
This will record the macro (in register a
) of you adding "private readonly string " to the beginning of the line, then moving one line down. If you want to repeat this macro twice (thus repeating the command for the next two lines), in command mode type 2@a
on the lastName
line, which will execute the macro twice more.
This method fulfills your requirement of "not manually visiting each line"; however it's a little heavyweight for your application.
If it's the typing of private readonly string
that you object to, a quick solution is to make your edit on the first line, then move down to each line you want to make the edit and use .
in Normal mode. This will repeat your last command (in this case adding the text to the line) with no fuss.
cool, I was actually looking for a way to repeat
.
but I guess it's not possible in this case... – Mauricio Scheffer – 2011-03-11T21:38:07.563@muasch: Well, you can, you'd just use
qa.jq
as your macro (repeat command, then go one line down), and use2@a
to replay it. It's a little messy though. – Zeke – 2011-03-11T21:47:18.240+1 The qa ... q macro is flexible and can solve a lot of problems, it's good to know. A little overkill for this question, but it will probably save you a lot of time in the future. – Johan – 2011-03-17T07:48:23.017