PowerShell Studio: Code Formatting
- Written by David Corrales
- Last Updated: 21 April 2016
- Created: 10 June 2014
- Hits: 3559
Often times when you paste a PowerShell script from the web, the lines aren’t indented correctly. With the PowerShell Studio’s code formatting, it will automatically indent your script.
Formatted After Paste:
PowerShell Studio’s code formatting is customizable to fit your needs:
The first few options serve as triggers for auto formatting. These options tell PowerShell Studio when to format your script.
The following triggers can be enabled:
- When a user inserts a new line ie. presses Enter (Formats the line only).
- When a script block is completed by typing the closing curly bracket } (Formats the code block).
- When a user types a semicolon ; (Formats the line only).
- When a user pastes text into the editor (Formats the pasted content).
In addition, there is an option to automatically indent the appropriate tab depth when inserting a new line.
The second set of options allow you to customize the formatting rules of PowerShell Studio.
Place open brace on new line:
Place statement keyword on newline:
Enabled (with open brace new line: disabled)
Disabled (with open brace new line: disabled)
Align parameter on line continue `:
Parameter Block Indent:
Indents the parameter declarations within a parameter block.
Align parameter attributes:
Vertically aligns a parameter’s attributes declarations. When disabled it uses the Attribute Parameter indent value instead, to indent the subsequent lines of attributes.
If you have any suggests or formatting options you would like to see added, please post a comment in our Wish List and Features Request forum.