claf
claf

Reputation: 9263

Using diffget in vimdiff

I'm trying to learn to use vimdiff well. Currently I figured out how to get a block of diff from a buffer to another (using do) but what I'm willing to do now is to simply get one (or some) line of a block in the other buffer.

The vimdiff documentation says:

:[range]diffget

but I can't figure how to have a correct range parameter to simply copy the line I'm on from a buffer to the other.

Upvotes: 9

Views: 9179

Answers (3)

dotancohen
dotancohen

Reputation: 31521

I find it a bit easier to select the current line with V and then to do or dp. This has the same effect as selecting the rage with :.,. but it is easier to type! Also, you can easily add adjacent lines with j or k.

Upvotes: 2

sjbrown
sjbrown

Reputation: 570

As Mykola said, :.,. will specify "the current line" as the range.

I had a very large file that needed each line inspected and perhaps changed, so typing ":.,.diffput" each time was too arduous. I recorded a macro:

qq:.,.diffput[ENTER]q

That created a macro (saved under the "q" key) to "put" a single line from the left buffer into the right buffer. Now to repeat this action, all I have to do is type "@q"

Upvotes: 1

Mykola Golubyev
Mykola Golubyev

Reputation: 59912

You can use

:.,.

as range from current line to the current line.

According to the doc you can omit range and then current line or line above will be used.

Upvotes: 11

Related Questions