March
18th,
2008
I've been using Vim to edit my PowerShell scripts for a while. I get full syntax highlighting and indentation thanks to Peter Provost's excellent scripts:
- Syntax file
- Indent file
- File Type Plugin file
These work great most of the time, but a couple of things had been nagging me for a while:
- I occasionally enable syntax-based folding (
:set foldmethod=syntax
), but the PS1 syntax file doesn't enable this for blocks "{...}" in PowerShell scripts. - The indent file always forces comments (#...) to start at the first column.
Fortunately, both of these issues are pretty easy to fix. To enable syntax-based folding, I just modified the syntax file to add this:
" support folding for blocks
syntax region psBlock start="{" end="}" transparent fold
To disable the comment indentation, I edited the Indent file and remove the # character as an indent key:
setlocal cindent cinoptions& cinoptions+=+0 cinkeys-=0#
Seems to be working fine for me, and it will now stop driving me crazy :-).
Technorati tags: Vim, PowerShell