Vim with Powershell

后端 未结 12 447
梦毁少年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 12:56

    I ran into a similar problem described by many here.

    Specifically, calling

    :set shell=powershell
    

    manually from within vim would cause powershell to work fine, but as soon as I added:

    set shell=powershell
    

    to my vimrc file I would get the error "Unable to open temp file .... "

    The problem is that by default when shell is modified, vim automatically sets shellxquote to " which means that shell commands will look like the following:

     powershell -c "cmd > tmpfile"
    

    Where as this command needs to look like this, in order for vim to read the temp file:

     powershell -c "cmd" > tmpfile
    

    Setting shellquote to " in my vimrc file and unsetting shellxquote (i.e. setting it to a blank space) seem to fix all my problems:

    set shell=powershell
    set shellcmdflag=-c
    set shellquote=\"
    set shellxquote=
    

    I've also tried taking this further and scripting vim a bit using the system() call: system() with powershell in vim

提交回复
热议问题