Vimdiff:如何将所有更改从一个文件放到另一个文件中? [英] Vimdiff: How to put all changes inside a particular function from one file to another?
问题描述
在Vimdiff中,我知道我可以使用"do"或"dp"将更改从一个文件移动到另一个文件...但是这些是针对单个更改的.如果我必须撤消特定作用域/选择内的所有更改(例如撤消对特定功能的所有更改,而其余部分保持不变),有没有办法一次性完成?
In Vimdiff, I know I can use "do" or "dp" to move changes from one file to the other...but these are for individual changes. If I have to undo all changes inside a specific scope/selection (say undo all changes to a particular function, but leave the rest untouched), is there a way to do it in one go ?
推荐答案
您可以使用视觉选择和ex命令:diffget
/:diffput
You can use a visual selection and the ex command :diffget
/:diffput
例如,仅获取代码块({...})当前内部的更改
So, for example to get the changes for just the current insides of a code block ( { ... } )
Vi}:diffget<Enter>
要放入两个封闭级别的更改,包括带有方括号的行:
To put the changes for the two enclosing levels including the lines with the brackets:
V2a}:diffput<Enter>
请注意,由于这些是ex命令,因此运动是沿行方向进行的.当然,您可以使用任何范围,因此您可以重复可视范围或使用标记
Note that since these are ex commands the motions are linewise. Of course, you could use any range, so you can repeat the visual range, or use markers
:'a,'bdiffput
等用你的想象力,这是vim:)
etc. Use your imagination, this is vim :)
这篇关于Vimdiff:如何将所有更改从一个文件放到另一个文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!