9

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.

Keith Pinson
  • 7,835
  • 7
  • 61
  • 104
claf
  • 9,043
  • 17
  • 62
  • 79

3 Answers3

11

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.

Mykola Golubyev
  • 57,943
  • 15
  • 89
  • 102
2

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.

dotancohen
  • 30,064
  • 36
  • 138
  • 197
1

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"

sjbrown
  • 562
  • 3
  • 5