0

Disclaimer: I know now to use vimdiff, dp, dg and the other commands related to diffing in Vim.

However, there's something which seems like it cannot be done.

I want to remap the cursor keys so that moves the difference to the right and moves the difference to the left regardless in which buffer the cursor is currently placed.

The issue is that vimdiff seems to have no understanding of a left or a right buffer, instead dp (or :diffput) moves the difference from the current window to the other window while dg (or :diffget) fetches the difference from the other window into the currently active one. But sometimes I place my cursor in the left window to put something to the right, sometimes the other way round. So I cannot simply map to be :diffput or :diffget, I need some context about in which buffer the cursor is currently placed.

How do I achieve this?

eckes
  • 64,417
  • 29
  • 168
  • 201
  • If you always use vimdiff in a two window configuration you could possibly abuse `:help winnr` to determine if you are in the left or right window. You could try to protect against unexpected window configurations by ensuring that `winnr("$")` is 2. I hate to suggest this because it's not really a clean solution but it may work for your situation specifically. – Randy Morris Nov 09 '15 at 16:05
  • @RandyMorris: no I don't. Usually, I have 20 buffers ipen, then start staging files for Git using the **fugitive** plugin. This opens additional buffers... – eckes Nov 09 '15 at 16:44

1 Answers1

1

Each buffer has a number. If there are only two buffers they are 1 and 2. Left and right designations are never part of the model, but in most cases 1 is on the left with values increasing to the right (assuming horizontal split and that the buffers are still in their initial positions). The other buffer to act on can be passed to diffget and diffput. This is not a complete solution to your problem, but hopefully it will get you started.

hildred
  • 453
  • 11
  • 29