[http://candland.net/assets/binary/PowerVimsetupVIMtousePowershell_DAD5/vim_logo_2.png]

I’m using VIM more and more and have come to the point where issuing commands to the shell would be useful, the problem is I use PowerShell. This is fairly easy to setup in VIM, but I did hit two things that needed to be worked around. Script execution issues and my ps profile script changing directories.

First script execution, by default, does not allow custom scripts, like your modified ps profile. This was easy to take care of in the _vimrc file. Here’s what I added to setup PowerShell:

 # change to powershell       
 set shell=powershell.exe\ -ExecutionPolicy\ Unrestricted
 set shellcmdflag=-Command
 set shellpipe=>       
 set shellredir=>

You should also make sure to set your VIM encoding=utf-8. With that in place, PowerShell can be invoked and it will load your profile. However…

My profile always sets the current directory to my projects folder, which is good except when it’s being opened by VIM. Here’s my fix.

if ($HOME -eq $pwd.path) { 
   cd $projects 
}

With those changes in place I can now issue PowerShell commands from within VIM.