O'Reilly logo

Windows PowerShell™ Scripting Guide by Ed Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Formatting Your Code

Screen space should be conserved as much as possible while still allowing code formatting to reflect logic structure and nesting. Here are a few suggestions:

  • Indent standard nested blocks two spaces.

  • Block overview comments for a function. Block the highest level statements, with each nested block indented an additional two spaces.

  • You must line up curly brackets. This makes it easier to follow the code flow.

  • Avoid single-line statements. In addition to making it easier to follow the flow of the code, this also makes it easier when you search for a missing curly bracket.

  • Break each pipelined object at the pipe. Leave all pipes on the right.

  • Avoid line continuation—the grave accent (backtick or `). The exception here is when it would ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required