Suppose you have this text:
name1 = "John"; age1 = 41;
name2 = "Jane"; age2 = 32;
name3 = "Mike"; age3 = 36;
...
and you want to split each line into two lines to give a result like this:
name1 = "John";
age1 = 41;
name2 = "Jane";
age2 = 32;
name3 = "Mike";
age3 = 36;
...
How would you automate this operation?
Some notes:
- I already tried the following method:
(1) Select the text in virtual-vode,
(2) Execute:'<,'>:norm ^3f r^M
***,
but it doesn't work correctly; it splits only half of the lines, because after every line is broken, the next repetition of the command applies to the rest of the broken line instead on the next line! - This can be achieved using a macro but I'm looking for more elegant solution.
*** explanation of the sequence:
-norm
for executing the following commands in normal-mode
-^
for moving the cursor to the beginning of the line
-3f<space>
for moving the cursor to the 3rd space in the line
-r^M
for replacing that space with a new-line