Enhancing ps1.vim

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:

ps1vim

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

Comments (2)

David MohundroMarch 5th, 2009 at 6:43 am

Nice! I had added support for the multi-line comments to my version, but the string interpolation support makes this one far better. Thanks!

[...] was kind enough to point out a small missing thing in the expressions for built-in variables in my modified syntax file for PowerShell scripts for Vim. I’ve now updated the syntax file in my github repository [...]

Leave a comment

Your comment