Configure settings to auto format PowerShell code
After watching an interesting video from Trevor Sullivan about how to configure Visual Studio Code for PowerShell development, I found the following settings great for my personal preferences.
NOTE: Others might not prefer this type of style, but it works well for me.
1
{
2
"editor.minimap.enabled": true,
3
"workbench.iconTheme": "vscode-icons",
4
5
"powershell.scriptAnalysis.enable": true,
6
"terminal.integrated.shell.osx": "/usr/local/bin/powershell",
7
"powershell.integratedConsole.focusConsoleOnExecute": false,
8
"powershell.codeFormatting.newLineAfterOpenBrace": false,
9
"powershell.codeFormatting.whitespaceBeforeOpenParen": true,
10
"powershell.codeFormatting.ignoreOneLineBlock": true,
11
"powershell.codeFormatting.newLineAfterCloseBrace": true,
12
"powershell.codeFormatting.alignPropertyValuePairs": true,
13
"powershell.codeFormatting.whitespaceAfterSeparator": true,
14
"powershell.codeFormatting.whitespaceAroundOperator": true,
15
"powershell.codeFormatting.openBraceOnSameLine": false,
16
"editor.formatOnSave": true,
17
"editor.formatOnType": true
18
}
Copied!
As you type and when you save PowerShell files, they are auto formatted. Also the Script Analyst is enabled.
Pretty cool! :)
Last modified 2yr ago
Copy link