1

I am using Mobaxterm which has cygwin tools.

vim/gvim are working fine. I am using same vimrc file for both (with -u option). Note that I have same issue without any vimrc file.

To make vimdiff works, I had to define diffexpr this way:

function MyDiffWin()
  let opt = ""
  if &diffopt =~ "icase"
    let opt = opt . "-i "
  endif
  if &diffopt =~ "iwhite"
    let opt = opt . "-b "
  endif
  execute '! ls '. v:fname_in
  silent execute "!/bin/diff.exe -a --binary " . opt . v:fname_in . " " . v:fname_new . " > " . v:fname_out
endfunction
set diffexpr=MyDiff()

But when I try to use gvimdiff, with same vimrc, I have the same issue I had with vimdiff without diffexpr :

E810: Cannot read or write temp files 
E97: Cannot create diffs

I tried to display the files used by diff.exe with the command execute '! ls '. v:fname_in But it does not display anything :

:! ls /home/mobaxterm/tmp/vD9PXDX/0

Command terminated

So not surprising he cannot diff files ! But I do not understand the problem.

vim and gvim are in version 8.0.494

TIA

JP

  • What about gvim? Do you have the Cygwin version and does it work (with same vimrc)? – B Layer Feb 25 '18 at 13:00
  • I have not installed the cygwin version. However I installed the windows gvim version and diff is working great with same vimrc. The only problem is that I have not succedeed to launch it from mobaxterm. Probably due to the fact that it can't find the windows diff.exe version plus other path issues. – JPMous Feb 26 '18 at 19:09
1

I was facing the same problem in MobaXTerm for a long time up to version 11.1. The reason (and solution) I finally found is twofold:

  1. E810 is about Vim being unable to write and read temporary files. If you run fugitive you get E484 about the same.

  2. E97 is about wrong output of the diff executable called by Vim.

Resolving E810 and E484

In my case it was about wrong set shellxquote=\", which I got during my searching for a solution. That setting is responsible for how Vim quotes filenames. Removing it, resulting in unsetting, resolved the error with writing and reading temporary files.

Resolving E97

This is where the diffexpr comes to help. But it might not be sufficient itself. In my case I had to install diffutils package too as the /bin/diff was pointing to busybox, which supports only the unified diff format, while Vim requires ed-style (i.e. normal) diff format.

Now my diff executables are:

lrwxrwxrwx     16 Jan 29 13:26 /bin/diff -> /bin/busybox.exe*
-rwxr-xr-x 201.5K Dec  6  2016 /bin/diff.exe*
-rwxr-xr-x  56.0K Dec  6  2016 /bin/diff3.exe*

The difference in output is:

$ /bin/diff one two
--- one
+++ two
@@ -1,3 +1,3 @@
 no change
-file one
+file two
 no change

$ /bin/diff.exe one two
2c2
< file one
---
> file two

All that needs to be done is to point to the proper one in the diffexpr function:

silent execute "!/bin/diff.exe  " . opt . v:fname_in . " " . v:fname_new . " > " . v:fname_out

Even the -a --binary options are not required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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