PowerShell Studio 2014: Code Formatting

June 10th, 2014 by David Corrales
Last updated on May 30th, 2014

 

One of the new features we added to PowerShell Studio 2014 is code formatting. PowerShell Studio 2014 will now beautify your script while you type or when you paste content.

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.

image

Formatted After Paste:

image

 

Customizable Formatting:

PowerShell Studio 2014’s code formatting is customizable to fit your needs:

image

Formatting Triggers:

The first few options serve as triggers for auto formatting. These options tell PowerShell Studio when to format your script.

image

The following triggers can be enabled:

  1. When a user inserts a new line ie. presses Enter (Formats the line only).
  2. When a script block is completed by typing the closing curly bracket }  (Formats the code block).
  3. When a user types a semicolon ; (Formats the line only).
  4. 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.

Formatting Rules:

The second set of options allow you to customize the formatting rules of PowerShell Studio 2014.

Place open brace on new line:

Enabled

image
Disabled
image

Place statement keyword on newline:

Enabled (with open brace new line: disabled)
image

Disabled (with open brace new line: disabled)
image

Align parameter on line continue `:

Enabled

image

Disabled

image

Parameter Block Indent:
Indents the parameter declarations within a parameter block.

Indent: 1

SNAGHTML145d742

Indent: 0

image

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.

Enabled
SNAGHTML1483f28

Disabled with Indent: 1
SNAGHTML149e97a

 

Let us know what you think. 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.

 

 
[Google+]   [Facebook]   [LinkedIn]   [StumbleUpon]   [Digg]   [Reddit]   [Google Bookmark]  

Tags: , , ,