5

while giving the dp command in vimdiff it replaces the entire block(2 lines) with pink colour on left hand side file to right hand side file.

In that block if i want to merge only the second line. First line should not be Merged.

VINOTH ENERGETIC
  • 1,775
  • 4
  • 23
  • 38

2 Answers2

5

Go to the one line that you need to be overwritten:

:.diffget

Or just:

:.diffg

If you want to re-calculate the "pink areas" now:

:diffu

If the line is absent, it's best to hit O to add an empty line and then do a :.diffg

Just adding it as an answer, so people can vote on it. For me it works better (when bound to a key combo) than do or dp.

kubanczyk
  • 5,184
  • 1
  • 41
  • 52
4

You can just copy the part of the code you want to copy over using:

  1. Hit the V key and then select just the text you want to move; and then hit yy to yank it.
  2. Press CTRL+ww to switch windows, and then move your cursor to the desired location
  3. Finally, press p to paste it in the desired location.
leeand00
  • 25,510
  • 39
  • 140
  • 297
  • 2
    @vinothcse2000: There is no direct command, you have to build a custom mapping / command, using the basic steps outlined here. – Ingo Karkat May 13 '15 at 12:47
  • @IngoKarkat: what about `:diffput` in visual mode or with range `:.diffput`? Its results vary, but it does something reasonable in some cases. – xaizek May 13 '15 at 12:54
  • @xaizek: As far as I can remember, it doesn't yield results you can depend upon (without further inspection). That's why I wrote such wrapper for myself a long time ago, too. – Ingo Karkat May 13 '15 at 12:59
  • 1
    If one presses `yy` no `V` is ever needed in fact. – poige May 16 '20 at 13:56