2

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).

2

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

                        *E810* *E97*
Vim will do a test if the diff output looks alright.  If it doesn't, you will
get an error message.  Possible causes:
-  The "diff" program cannot be executed.
-  The "diff" program doesn't produce normal "ed" style diffs (see above).
-  The 'shell' and associated options are not set correctly.  Try if filtering
   works with a command like ":!sort".
-  You are using 'diffexpr' and it doesn't work.
If it's not clear what the problem is set the 'verbose' option to one or more
to see more messages.

The self-installing Vim for MS-Windows includes a diff program.  If you don't
have it you might want to download a diff.exe.  For example from
http://gnuwin32.sourceforge.net/packages/diffutils.htm.

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")
                global
        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

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.