There seems to have been a change in git which makes it no longer work correctly with gvim as the diff tool. Specifically, I always used to use the gvim -geometry flag to maximize the window. Now, I end up with one of the windows blank (empty/zero line file).
-
We would have needed your actual git config to help. Also, when you speculate about a "change in git", it would make sense to mention the Git version(s), right?! – Ingo Karkat Oct 24 '14 at 19:34
2 Answers
OK, I found the answer. In order to work correctly, gvim must stay in the foreground and NOT fork a new process as usual. This is accomplished by using the -f
or --nofork
flag when starting gvim (or gvimdiff).
I have now setup the following alias which works:
alias gitdg='git difftool --noprompt --extcmd="gvim -d --nofork -geometry 220x80+2000+40" '
Please be careful to note the placement of single- vs. double-quotes to keep the zsh shell happy.
I used the gvim option -geometry
to configure the diff windows to have 220 lines x 80 columns. The "+2000+40" means the upper left corner of window to be offset of 2000 pixels horizontally and 80 pixels vertically from the top-left corner of all monitors, so the window appears on the right monitor of my 2-monitor setup. Try setting it to -geometry 160x40+60+20
to see the effect of changes.

- 852
- 2
- 11
- 26

- 29,276
- 6
- 41
- 48
-
1You can also substitute "gvimdiff" in place of "gvim -d" if you wish. – Alan Thompson Oct 24 '14 at 19:34
-
1On Windows Server 2012R2 I was able to use `git difftool --no-prompt --extcmd="'C:\Program Files (x86)\Vim\vim81\gvim' -d -f"` the above got me to where I needed to be. Thx. – Jim Nov 29 '18 at 13:59
On Windows Server 2012R2, adding the following to my .gitconfig worked for me as well. My experience was that the -d and -f were not necessary for my setup. Even though this is Windows, assure you use forward slashes '/' for the path information.
[alias]
d = difftool
[diff]
tool = gvimdiff
[difftool]
prompt = false
[difftool "gvimdiff"]
path = "C:/Program Files (x86)/Vim/vim81/gvim.exe"
Sample Run ...
c:\>git d index.html
I also discovered I had defined a function for diffexpr in my _vimrc, this needed commented out like so ...
"set diffexpr=MyDiff()
... which allows the 'new' built-in diff to work within gVim. With those changes, everything worked in gui vim.

- 359
- 2
- 15