9

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 ?

4

1 回答 1

14

您可以使用视觉选择和 ex 命令:diffget/:diffput

因此,例如,仅获取代码块当前内部的更改( { ... } )

Vi}:diffget<Enter>

放置两个封闭级别的更改,包括带括号的行:

V2a}:diffput<Enter>

请注意,由于这些是 ex 命令,因此运动是线性的。当然,您可以使用任何范围,因此您可以重复可视范围,或使用标记

:'a,'bdiffput

等等。发挥你的想象力,这就是 vim :)

于 2011-05-23T06:58:58.217 回答