blindpete.com

Just my rambles

Using Notepad++ For PowerShell Editing

The style I use has a nice black background...

The style I use has a nice black background…

A while back Thell Fowler (with a little help, and a lot of testing from me) wrote a very good PowerShell Lexer for Notepad++ 5.2 and later… it’s very thorough, has good code-folding, and full support for PowerShell 2.0 syntax highlighting.

I mention this because Notepad++ 5.6 just released yesterday, and it has built-in support for PowerShell syntax courtesy of Scintilla … but it’s very, very bad. The scintilla PowerShell lexer is probably the most minimal PowerShell lexer I’ve seen (it’s worse than the old “user style” I had created for Notepad++) and has no support for:

  • The ` escape character
  • Here-strings (which can contain quotes, etc)
  • The difference between strings and literal strings and literal here-strings
  • The begin/process/end block keywords and Param()
  • PowerShell operators (like -is or -gt or -notcontains)
  • [System.Namespace.Class]::Method() syntaxes
  • Nested $variables inside strings
  • Nested $( code blocks ) inside strings (with strings inside those, and …)
  • Any of the new PowerShell 2 syntax like:
    • multi-line comments
    • [Parameter()] and [Alias()] and [Validate …. ]
  • [CmdletBinding()]

There’s probably more, but I couldn’t be bothered to spend more than a couple of minutes with it. As you can probably guess … all of those features are supported by the external PowerShell Lexer plugin that Thell wrote, so if you’re a PowerShell and Notepad++ user, I apologize for not drawing your attention to our PowerShell Lexer for Notepad++ before :) .

Incidentally, I stuck a screenshot in this post so you can see how I use it, but there’s one a more complete example of the PowerShell Syntax Highlighting on that lexer download page. ;-)

Reblog this post [with Zemanta]

Posted via web from blindpete’s posterous

Leave a Reply