Vim with Powershell

后端 未结 12 462
梦毁少年i
梦毁少年i 2020-12-07 12:42

I\'m using gvim on Windows.

In my _vimrc I\'ve added:

set shell=powershell.exe
set shellcmdflag=-c
set shellpipe=>
set shellredir=>

function!          


        
12条回答
  •  一生所求
    2020-12-07 13:14

    Try instead set shellcmdflag=\ -c


    Explanation:

    Vim uses tempname() to generate a temp file path that system() reads.

    If &shell contains 'sh' and &shellcmdflag starts with '-' then tempname() generates a temp file path with forward slashes.

    Thus, if set shell=powershell set shellcmdflag=-c then Vim will try to read a temp file with forward slashes that cannot be found.

    A remedy is to set instead set shellcmdflag=\ -c that is, add a whitespace to &shellcmdflag so that the first character is no longer '-' and tempname() produces a temp file path with backward slashes that can be found by system().


    I remarked on the vim_dev mailing list ( https://groups.google.com/forum/#!topic/vim_dev/vTR05EZyfE0 ) that this deserves better documentation.

提交回复
热议问题