假设我有这两个块:
1
23
456
hello..
world world
codecode
然后我需要这个块(在 1 和 hello .. 之间,之间没有任何空格):
1hello..
23world world
456codecode
什么是最好的快捷方式?
我在windows xp和windows 7上使用了gvim7.3.46
这是我的_vimrc
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction
我使用C-r"
,但这不起作用。
1
23
456
hello..
world world
codecode
我使用了C-q
,y
,C-p
,结果是:
1
23
456
1 hello..
23 world world
456codecode
答案 0 :(得分:3)
将光标放在1
。
点击<C-v>
进入可视屏蔽模式。
将光标向下移动到456
并点击$
以选择整个区块。
点击y
以阻止该区块。
将光标放在h
中的hello
。
点击P
。
答案 1 :(得分:3)
我会使用视觉阻止模式。这样做:
<C-v>
进入可视区块模式。$
将选择范围扩展到行尾。d
删除第一个块。这也将复制它。P
,将第一个块粘贴到第二个块之前,中间没有空格。第一行范围将为空,因此如果您不想要它们,则必须删除这些行。
答案 2 :(得分:1)
使用递归宏在两个块之间来回跳转,删除和连接线:
qq}jdd''pkgJj@qq
值得注意的击键:
''
跳回到您最近跳过的@q
从q
q
gJ
加入两行,但两行之间没有空格