Powershell 2.0 features not coveredEdit
Version 2.7 of the Powershell syntax file (ps1.vim) does not cater for block comments (<# ... #>) and doesn't recognise the new Powershell 2.0 exception handling keywords (try, catch, finally). There are probably other Powershell 2.0 changes that are not covered, but these are all I have noticed so far.
I recommend adding the following to handle the comments:
syn region ps1Comment start=/<#/ end=/#>/ contains=ps1CommentTodo
throw from line 35 and adding these two lines in the appropriate places (lines 36 and 100 respectively) to handle exception keywords
syn keyword ps1Exception trap throw try catch finally HiLink ps1Exception Exception
dutchie 18.104.22.168 08:29, September 17, 2010 (UTC)
Comment based helpEdit
I use the following for comment based help.
syn match ps1CommentHelp /\.\(synopsis\|description\|parameter\|example\|inputs\)/ contained display syn match ps1CommentHelp /\.\(outputs\|notes\|link\|component\|role\|functionality\)/ contained display syn match ps1CommentHelp /\.\(forwardhelptargetname\|forwardhelpcategory\)/ contained display syn match ps1CommentHelp /\.\(remotehelprunspace\|externalhelp\)/ contained display syn region ps1MultiLineComment start=/<#/ end=/#>/ fold contains=ps1CommentHelp HiLink ps1MultiLineComment Comment HiLink ps1CommentHelp SpecialCommentThe HiLink commands need to go at the bottom with the other HiLink commands. My personal preference is that multi-line comments should not contain TODOs so I've left them out. If you want TODOs in multi-line comments change ps1MultiLineComment to
syn region ps1MultiLineComment start=/<#/ end=/#>/ fold contains=ps1CommentHelp,ps1CommentTodo
chilversc 11:24, June 09, 2011 (BST)
Nice job. I've been using zsh/z-shell highlighting on posh for a bit over a year. It'll be good to have something that knows about backslashes. If I find any problems, I'll either submit a fix of give a shout. Thanks for the eye-candy.
Just a note to *nix users who want to do PowerShell development on *nix machines - do a dos2unix convert on the files prior to loading them into their respective directories. Works brilliantly once you do.