Editing PowerShell Scripts with Vim

Link. March 18, 2008. Comments [0]. Posted in: PowerShell | Vim

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:

These work great most of the time, but a couple of things had been nagging me for a while:

  1. I occasionally enable syntax-based folding (:set foldmethod=syntax), but the PS1 syntax file doesn't enable this for blocks "{...}" in PowerShell scripts.
  2. 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 :-).



Comments are closed.

About

Tomas Restrepo is co-founder of devdeo. His interests include .NET, Connected Systems, PowerShell and, lately, dynamic programming languages. More...

email: tomas@winterdom.com
msn: tomasr@passport.com
twitter: tomasrestrepo

Technorati Profile

devdeo logo

View my profile on LinkedIn

MVP logo

Syndicate

Ads


Links

Categories

Statistics

Total Posts: 1014
This Year: 84
This Month: 3
This Week: 2
Comments: 776

Blogroll

Post Archive

Other

Copyright © 2002-2008, Tomas Restrepo.

Powered by: newtelligence dasBlog 2.1.8102.813

Sign In