views:

221

answers:

1

I've read Vimdiff and Viewing differences with Vimdiff plus doing various google searches using things like "vimdiff multiple", "vimdiff git", "vimdiff commands" etc.

When using do or diffg I get the error "More than two buffers in diff mode, don't know which one to use".

When using diffg v:fname_in I get "No matching buffer for v:fname_in".

From the vimdiff documentation:

:[range]diffg[et] [bufspec]
Modify the current buffer to undo difference with another buffer. If [bufspec] is given, that buffer is used. If [bufspec] refers to the current buffer then nothing happens. Otherwise this only works if there is one other buffer in diff mode.

and more:

When 'diffexpr' is not empty, Vim evaluates to obtain a diff file in the format mentioned. These variables are set to the file names used:

v:fname_in original file
v:fname_new new version of the same file
v:fname_out resulting diff file

So, I need to get the name of bufspec, but the default variables (fname_in, fname_new, and fname_out) aren't set.

I ran the command git mergetool on a linux box through a terminal.

[Edit] A partial solution that bred more questions. I used the "filename" at the bottom of the buffer. It's only a half answer, because occasionally I get a file does not exist error. I believe it's consistently the remote version of the file that "does not exist". I suspect this has something to do with git and indexing.

How do you get the bufspec value consistently while using vimdiff through git-mergetool?

+1  A: 

The [bufspec] argument above can be a buffer number, a pattern for a buffer name or a part of a buffer name. Examples:

:diffget Use the other buffer which is in diff mode :diffget 3 Use buffer 3 :diffget v2 Use the buffer which matches "v2" and is in diff mode (e.g., "file.c.v2")

I always use the number of the buffer.

nono
So use :diffget and whatever is the character combo after the second dot?
Elizabeth Buckwalter
That's awesome. You'd think that would've been easy to guess. Guess I was getting too irritated to see something so simple. *sigh* Thank you Thank you!
Elizabeth Buckwalter