有没有一种专门的方法可以通过插入行来合并两个文本块,就像从下面这样传递:
a1
a2
a3
a4
b1
b2
b3
b4
对此:
a1
b1
a2
b2
a3
b3
a4
b4
在几个命令?
编辑:我真的很喜欢佐藤桂的解决方案,这是我如何实现它:
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>
scroll-binding
两个Vim窗口。
b1
,然后单击vip
以选择整个块,然后,it
是<map-I've-Picked>
。是不是在你这边工作?