Vim with Powershell

It is a bit of a hack, but the following works in Vim 7.2. Notice, I am running Powershell within a CMD session.

if has("win32")
    set shell=cmd.exe
    set shellcmdflag=/c\ powershell.exe\ -NoLogo\ -NoProfile\ -NonInteractive\ -ExecutionPolicy\ RemoteSigned
    set shellpipe=|
    set shellredir=>
endif

function! Test()
  echo system("dir -name")
endfunction

Tested with the following…

  • :!dir -name
  • :call Test()

Leave a Comment