Merging vertical lists in Vim

Is there a way that allows me to combine lists vertically?

For example, if I have these two lists:

AE BF CG DH 

I would like to get the following:

 A E B F C G D H 
+7
list vim
source share
3 answers

It's simple, just place the cursor on the column between the lists. Insert visualblock-mode <Cv> , check the entire column, press r to replace it, then <CR> and you have what you want.

+12
source share
 :%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 
+2
source share

You can also do this with an external filter. Mark the corresponding lines in visual mode and press ! . The following filter does what you want on a POSIX system:

 paste -sd' ' | tr ' ' '\n' 
+1
source share

All Articles