Why doesn't "Diff with Vim" command work?
I am running gVim on WinXP.
I open a folder, select two files, and click "Diff with Vim". Screenshot:
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:
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开发者_如何学JAVA 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.
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.
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.
精彩评论