I use the excellent ps1.vim script originally written by Peter Provost to provide syntax highlighting for PowerShell scripts in Vim, and I’ve been very happy with it in general. However, PowerShell V2 is coming with a few extra syntax enhancements and there were always a couple minor issues that bugged me with the existing syntax.

So I spent some time adding a few extensions to ps1.vim to improve some of this. The changes include:

  • Support for Block Comments (<#…#>)
  • Highlighting documentation “tags” in comments (things like .Synopsis, .Parameter and so forth).
  • Highlighting variable usage in “” strings, as well as string interpolations
  • Highlighting special characters in strings (`n, `r and so on).
  • Highlighting for hex numbers
  • Different highlighting for Booleans ($false, $true), known constants ($null) and other built-in variables.

I’ve committed the updated ps1.vim script to my dotfiles repository. Here’s a small sample of what the changes look like:


It’s not much, but I think it’s going to be useful.

Tomas Restrepo

Software developer located in Colombia. Sr. PFE at Microsoft.