Is there a dedicated way to merge two blocks of text by interleaving lines, like passing from this:
a1 a2 a3 a4 b1 b2 b3 b4
a1 b1 a2 b2 a3 b3 a4 b4
in a few commands?
EDIT: I really like Sato Katsura's solution, here is how I have implemented it:
function! Interleave() " retrieve last selected area position and size let start = line(".") execute "normal! gvo\<esc>" let end = line(".") let [start, end] = sort([start, end], "n") let size = (end - start + 1) / 2 " and interleave! for i in range(size - 1) execute (start + size + i). 'm' .(start + 2 * i) endfor endfunction " Select your two contiguous, same-sized blocks, and use it to Interleave ;) vnoremap <pickYourMap> <esc>:call Interleave()<CR>