My settings for shell are:

set shell=powershell\ -ExecutionPolicy\ Unrestricted\ -NoProfile\ -NoLogo\ -NonInteractive
set shellcmdflag=-Command 

And when i'm using that, I'm getting following error

E97: Cannot create diffs

But when I revert back to default windows shell (cmd) that's working fine.

I tried to set shell in diffexpr function, but got an error on calling diff.exe (I haven't found error message).


Every time you receive an error from Vim, you can use lookup the documentation for more information. In this case, :help E97:

                        *E810* *E97*
get an error message.  Possible causes:
-  The "diff" program cannot be executed.
   works with a command like ":!sort".
-  You are using 'diffexpr' and it doesn't work.
to see more messages.


Based on that explanation you could try:

  1. Ensure that you have the diff program on powershell. Maybe by changing the default shell you prevent Vim from reaching the diff program it installs on Windows (as stated in the last paragraph)
  2. Check all shell related options. From :help 'shell':

    'shell' 'sh'        string  (default $SHELL or "sh",
                        MS-DOS and Win32: "command.com" or
                        "cmd.exe", OS/2: "cmd")
        Name of the shell to use for ! and :! commands.  When changing the
        value also check these options: 'shelltype', 'shellpipe', 'shellslash'
        'shellredir', 'shellquote', 'shellxquote' and 'shellcmdflag'.
  3. Try using the 'verbose' option (or the :10verbose <cmd> command) to find what is the string Vim is trying to pass to the command line. Then you could try to call that line directly on your shell, where it would be easier to debug it.

Your Answer

