Question
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.
Solution
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.
OTHER TIPS
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"
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.