简体   繁体   English

为什么“Diff with Vim”命令不起作用?

[英]Why doesn't “Diff with Vim” command work?

I am running gVim on WinXP. 我在WinXP上运行gVim。

I open a folder, select two files, and click "Diff with Vim". 我打开一个文件夹,选择两个文件,然后单击“Diff with Vim”。 Screenshot: 截图:

Vimdiff问题

The gVim GUI starts up, with each of the files in its own tab. gVim GUI启动,每个文件都在自己的选项卡中。 I notice that each tab is in DIFF mode. 我注意到每个选项卡都处于DIFF模式。 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: 两个文件完全不同,但没有突出显示,没有 - 只是左边的灰线,我将其解释为'DIFF'模式:

差异的结果

What is going on? 到底是怎么回事? Is my vimdiff not working or is it something else? 我的vimdiff不工作还是别的什么?


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 之前,当我需要使用Windows上下文菜单打开多个选项卡中的文件时 ,我按照海报的建议并将以下行添加到我的.vimrc文件中: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. 虽然这允许我在单个Vim窗口中的单独选项卡中打开两个文件,但如果我愿意,我将无法区分这两个文件。 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 . 开启这两个功能的解决方案是使autocmd上面仅在我不想diff的两个文件,这发生在的情况下&diff==0 Thus, when I modified the code in my .vimrc file to the below, I regained my Diff with Vim functionality: 因此,当我将.vimrc文件中的代码修改为以下内容时,我重新获得了我的Diff with Vim功能:

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. 我还将此解决方案添加到上面提到的Vim Wikia链接的评论部分。

This is at best a hint, since I don't run windows or even use gvim under linux. 这充其量只是一个提示,因为我不运行Windows甚至在linux下使用gvim If the option -p is supplied to vimdiff , it will open its arguments in separate tabs. 如果将选项-p提供给vimdiff ,它将在单独的选项卡中打开其参数。 Since diffing is only done across windows in the same tab, this effectively disables diffing. 由于仅在相同选项卡中的窗口之间进行差异,因此这有效地禁用了差异。 -p still available because vimdiff just calls vim -d ... . -p仍然可用,因为vimdiff只是调用vim -d ... The -p tells vim to put each argument in a separate tab; -p告诉vim将每个参数放在一个单独的选项卡中; it is pretty useful when normally invoking vim. 通常调用vim时它非常有用。 So it may be that you've somehow got vim configured to always do this. 所以可能是你以某种方式让vim配置为始终这样做。

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. 我会检查Diff with Vim选项的Diff with Vim实际上做了什么并追踪它以查看调用链中的批处理文件(或者他们现在称之为的任何东西......)是否正在向你的vim的正常调用中添加-p选项。 IIRC you can do this from Windows Explorer; IIRC你可以从Windows资源管理器中执行此操作; there is an option in I think the View menu that shows you all filetypes. 我认为View菜单中有一个选项可以显示所有文件类型。 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 ) 如果我没错,gvim在它的stock _vimrc中定义了一个自定义的VimDiff()函数( :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. 您需要检查实际的功能名称和参数(如果有的话),因为我没有方便的Windows机器at.m.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM