Is there a way which allows me to merge lists vertically?
For example, if I have have these two lists:
A E
B F
C G
D H
I would like to end up with the following:
A
E
B
F
C
G
D
H
This is simple, just place the cursor on the column between the lists.
Insert visualblock-mode <C-v>
, mark the whole column, hit r
to replace it, and then <CR>
and you have what you want.
:%s/\v^(\w) /\1\r/g
: ........... command
% ........... whole file
\v .......... very magic (avoid backslashes)
(\w) ........ word character
\1 .......... all patter in parenthesis
\r .......... Carriage Return "Enter"
g ........... globally
You could also do it with an external filter. Mark the relevant lines in visual mode and press !. The following filter does what you want on a POSIX system:
paste -sd' ' | tr ' ' '\n'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With