3

I am running gVim on WinXP.

I open a folder, select two files, and click "Diff with Vim". Screenshot:

Vimdiff issue

The gVim GUI starts up, with each of the files in its own tab. I notice that each tab is in DIFF mode. However, there is no comparison being made between the two tabs. Both files are completely different, yet there is no highlighting, nothing - just a gray line on the left, which I interpret to be the 'DIFF' mode:

Result of diff

What is going on? Is my vimdiff not working or is it something else?


My SOLUTION

Earlier, when I needed to Open files in multiple tabs using the Windows Context Menu, I followed a poster's advice and added the following line to my .vimrc file: :autocmd BufReadPost * tab ball

While that allowed me to open two files in separate tabs in a single Vim window, I lost the ability to diff the two files, if I wanted to. The solution to turn on both these features is to enable the autocmd above only in the case where I do not want to diff the two files, which happens when &diff==0. Thus, when I modified the code in my .vimrc file to the below, I regained my Diff with Vim functionality:

if (&diff==0)
    :autocmd BufReadPost * tab ball
endif

I've also added this solution to the comments portion of the Vim Wikia link mentioned above.

drapkin11
  • 1,205
  • 2
  • 12
  • 24
  • do you see anything happen at all? It sounds like you should reinstall gvim. This works for me on XP with the latest vim. When I try this I see a command window and then see the vim window in diff mode with the two files. – IanNorton Apr 05 '11 at 20:34
  • have you tried the command `:diffthis` in each tab? Although this shouldn't be necessary. – David Brown Apr 05 '11 at 20:43
  • @David: the files are already in DIFF mode. But no, `:diffthis` does nothing new. – drapkin11 Apr 05 '11 at 20:50
  • @IanNorton, why did you retag (from gvim to vim)? My understanding was that it is possible to run a [Win32 console executable](ftp://ftp.vim.org/pub/vim/pc/vim73_46w32.zip) version of vim. – drapkin11 Apr 05 '11 at 20:55

2 Answers2

2

This is at best a hint, since I don't run windows or even use gvim under linux. If the option -p is supplied to vimdiff, it will open its arguments in separate tabs. Since diffing is only done across windows in the same tab, this effectively disables diffing. -p still available because vimdiff just calls vim -d .... The -p tells vim to put each argument in a separate tab; it is pretty useful when normally invoking vim. So it may be that you've somehow got vim configured to always do this.

I would check out what that Diff with Vim option actually does and trace it down to see if a batch file (or whatever they're called these days..) along the call chain is adding the -p option to your normal invocation of vim. IIRC you can do this from Windows Explorer; there is an option in I think the View menu that shows you all filetypes. You can view and edit the applications configured to "open" those filetypes.

intuited
  • 23,174
  • 7
  • 66
  • 88
  • Your post (as well as @sehe's) led me to the solution that works for me. I've posted it as an update to my question. Thanks! – drapkin11 Apr 11 '11 at 18:24
2

If I'm not wrong, gvim defines a custom VimDiff() function in it's stock _vimrc (:e +/Diff $MYVIMRC)

You might want to check whether it works by doing

 :call VimDiff()

You need to check the actual function name and parameters (if any) since I don't have a windows machine handy at.m.

sehe
  • 374,641
  • 47
  • 450
  • 633
  • Thanks, I found the function definition in _vimrc. It is called `MyDiff`, and it did, in fact, work when I called it. – drapkin11 Apr 11 '11 at 16:46