2

I use windows XP for testing and running some programs. I installed Vim on the machine, but when I run vimdiff on two files, I get the following error:

'""C:\Program' is not recognized as an internal or external command,
operable program or batch file.

along with errors E810 and E97.

Looking around the web, it seems that some variable in Vim is not quoted.

I think it's the VIMRUNTIME, but I'm not sure, and cannot find where to change it.

I'm using the default vimrc (_vimrc on windows).

As requested in the comments by @Ben, in order to run vimdiff I use the following command: vimdiff file1 file2.

3
  • 1
    The output actually makes me think you have a double-quoting issue. For debugging purposes, it may be useful for you to edit vimdiff.bat and remove the @echo off line at the top. Then edit the question with the output of running vimdiff, which should hopefully provide more details about where in the batch file the problem happens.
    – user72
    Commented Mar 6, 2015 at 17:01
  • How exactly are you invoking vimdiff, as well? Also see superuser.com/questions/697847/…
    – Ben
    Commented Mar 6, 2015 at 23:30
  • @JoshPetrie I don't have a diff.bat file, just a diff.exe and a few .vim and .txt files.
    – elyashiv
    Commented Mar 7, 2015 at 17:08

2 Answers 2

4

Getting a fixed Vim

This specific bug was fixed in 7.4.103 back in 2013. Bram typically only publishes Windows installers on vim.org for major releases, so the installer there doesn't have this fix.

The Cream project regularly builds a Windows installer containing the latest Vim patches and provides them in their Vim without Cream download. This is a commonly recommended resource for Windows users.

Using their installer and having it overwrite the common _vimrc will fix the MyDiff function.

Avoiding the problem

That being said, there's no need to use the MyDiff function defined in that _vimrc. If you just create your own $HOME\_vimrc, then the system one won't be used. This is what I do and have never had a problem using vimdiff on Windows without a custom 'diffexpr'.

I'd recommend creating your own _vimrc anyway so you can freely customize it without risking it being overwritten next time you upgrade Vim.

3
  • If there is no need for a MyDiff function, why does it exist?
    – elyashiv
    Commented Mar 8, 2015 at 6:42
  • @elyashiv The _vimrc isn't populated with required settings. It's just setting up some stuff that may or may not be useful to the user and providing some example settings. The MyDiff function would fall in the example category, IMO.
    – jamessan
    Commented Mar 10, 2015 at 13:35
  • For reference, here's another way: install Chocolatey, then run cinst vim from an administrator PowerShell (command prompt will work too, but PS is recommended). To upgrade it later, use cup vim. (The commands are short for chocolatey install vim and chocolatey upgrade vim, respectively. There's also a choco shorthand for chocolatey.)
    – user1230
    Commented Mar 11, 2015 at 14:34
2

I can reproduce the problem on my Windows 7 VM, I installed gVim, clicked the "install .bat files for commandline usage", typed vimdiff a.txt b.txt in a cmd window, and got the same error.

Here's how I fixed it:

  • :set diffexpr? gives diffexprr=MyDiff()

  • :echo $MYVIMRC gives me C:\Program Files\Vim\_vimrc; I opened this file and see the MyDifff() is defined here.

  • I copied this file to C:\Users\IEUser\_vimrc, I started Vim and used :echo $MYVIMRC again to verify it's actually being used. We can now use this file to fix the MyDiff() function.

  • On line 20, there's:

    let cmd = '""' . $VIMRUNTIME . '\diff"'
    

    The double "" is wrong, this is probably a typo, so remove one:

     let cmd = '"' . $VIMRUNTIME . '\diff"'
    
  • It still doesn't work :-/ I replaced the silent execute in the last line with echo, I notice that the command ends with a ", but I don't see an opening " anywhere. This is caused by the . eq part, so I removed that.

  • We now have a working vimdiff! I still need to press enter twice on startup, though; I am not sure why this is... If I run the command that Vim runs in cmd, it seems to work just fine ... This may have to do with the way Windows cmd.exe works, but I'm not sure...

I'm not sure the above is the best way to fix it, but it's a way. This is a bug in Vim; you should report it as such. Feel free to copy this post :-)

3
  • This is a bug in Vim; Actually, it's a bug in the _vimrc being installed by your installer. At a guess, that's probably the Vim without Cream installer. The problem should be reported there.
    – jamessan
    Commented Mar 7, 2015 at 20:15
  • @jamessan I downloaded the Vim installer from the vim.org site at vim.org/download.php ... I don't know anything about Cream. It seems to me that the _vimrc file that this installer installs is part of Vim? Commented Mar 7, 2015 at 20:22
  • Ah, well that's why it's generally recommended to get the 'Vim without Cream' installer on Windows. :) It is regularly rebuilt whereas the Windows installer from vim.org is usually only built for major releases. This bug was fixed in 2013, but the vim.org installer doesn't have the fix.
    – jamessan
    Commented Mar 7, 2015 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.