在比较文件和更新源代码存储库时,我喜欢使用 vimdiff。要将从一个文件所做的更改复制到另一个文件,我通常使用这样的键序列:-
Shift + V (select line)
k or j; { or }; Up or down arrow keys (select more lines)
y (copy selected lines)
Ctrl + w, left/right arrow (move to other pane)
p (paste lines)
Run Code Online (Sandbox Code Playgroud)
Vim 作为键盘快捷键的大师,肯定应该有更简单的方法来执行相同的任务。有吗?您使用什么来手动更新源代码更改?
Mar*_*rco 233
do(diff 获得) 和dp(diff put) 是您所需要的。以下是此上下文中其他有用的普通模式命令的小列表。
]c - advance to the next block with differences
[c - reverse search for the previous block with differences
do (diff obtain) - bring changes from the other file to the current file
dp (diff put) - send changes from the current file to the other file
zo - unfold/unhide text
zc - refold/rehide text
zr - unfold both files completely
zm - fold both files completely
Run Code Online (Sandbox Code Playgroud)
注意:
无论do和dp工作,如果你是一个块或正常模式下块只有一个行上而不是在视觉模式。在视觉模式下选择文本行时,必须使用普通命令
:'<,'>diffget 和:'<,'>diffput.另见:h copy-diffs。
:diffupdate 将重新扫描文件以进行更改。