Vimdiff failing with “Cannot read or write temp files”

后端 未结 7 604
一生所求
一生所求 2021-02-02 08:23

I\'m using Vim 7.4 on Windows 7.

I do have a custom _vimrc file, but both Vim and gVim work fine. When I try to run vimdiff .\\xxxxx .\\yyyyy, it gives the

7条回答
  •  鱼传尺愫
    2021-02-02 09:20

    This issue can be caused by the default _vimrc file created by the installer on Windows. If you're still using that default file, or if you copied it at some point, then check the function you've assigned to the diffexpr option. One of the patches between Vim 7.3 and 7.4 introduced new default quoting rules for the cmd.exe shell on Windows. This patch broke the workaround in the MyDiff() function designed to fix the same issue solved by the patch.

    The MyDiff() function was fixed by version 7.4.103 by fixing the installer. Here is the MyDiff() function which the latest installer will create for you if you just want to copy it to your _vimrc:

     function MyDiff()
       let opt = '-a --binary '
       if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
       if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
       let arg1 = v:fname_in
       if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
       let arg2 = v:fname_new
       if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
       let arg3 = v:fname_out
       if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
       if $VIMRUNTIME =~ ' '
         if &sh =~ '\ ' . arg3
       if exists('l:shxq_sav')
         let &shellxquote=l:shxq_sav
       endif
     endfunction
    

    You can see your full version in Vim using the :version or :intro commands, or at the splash screen at startup.

    The official Vim 8.0 installer is now available, or you can install a nightly build, install Vim from other places or build your own Vim. Installing with any of these methods should get you the latest default vimrc file if you want to grab the latest incarnation of this function.

    Copied from my answer to this same question on Super User.

提交回复
热议问题