The past few weeks I have had several people asking me about my Visual Studio Code (VSCode) setup for working with PowerShell, so I thought I’d write a blog about it. For those who don’t know about VSCode: It is the successor to the Windows PowerShell ISE that used to be shipped with Windows. The ISE is no longer under active development and not compatible with PowerShell 7. It’s successor VSCode is, and it is so much more at the same time.

Download and installation

VScode can be downloaded from https://code.visualstudio.com/download. For Windows, which is what I use and what this blog will be based on, you can download a user-based installer and a system installer. I use the system installer. You can also use a package manager like WinGet winget install --id Microsoft.VisualStudioCode or Chocolatey choco install vscode. Be sure to also install Git.
I’ve set Visual Studio Code as it’s default editor during install, I’ve left most of the other settings on their defaults.

Setting up for the first time

Upon first launch you can go through a walkthrough that will help you set things up a bit. I’ll point out a few extensions here as they enhance VSCode and will increase your experience by a huge amount!

Extensions

One of the steps in the walkthrough is choosing your language extensions, for this blog I’ll stick to what I use. Ofcourse, powershell is the first one, next is Github Copilot, then we setup the rest.

You can chose from an enourmous amount of extensions to use in VSCode, the extensions I use are: A number of these extensions are also part of the PowerShell Extension Pack as maintained by Justin Grote.

You’ll also be asked to install the latest powershell version which is 7.5 at the time of writing. Though you can skip this initially I recommend you do install it.

Layout and Settings

I moved the primary sidebar to the right so when I open or close it with Ctrl+B my code does not move. You can do this by right-clicking on the sidebar at the top and chosing “Move Primary Side Bar Right”. This allows for a more relaxed experience while working on a file with long lines of code. Another great thing about VSCode is that the settings are stored in a JSON file which allows for easy sharing of a setup, here’s part of what’s in my settings.json file.

"breadcrumbs.enabled": true,
"editor.bracketPairColorization.enabled": true,
"editor.codeLens": true,
"editor.defaultFormatter": "ms-vscode.powershell",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modifications",
"editor.formatOnType": true,
"editor.guides.bracketPairs": "active",
"editor.mouseWheelZoom": true,
"editor.parameterHints.cycle": true,
"editor.suggest.localityBonus": true,
"editor.suggest.shareSuggestSelections": true,
"editor.tabCompletion": "on",
"files.defaultLanguage": "powershell",
"files.autoGuessEncoding": true,
"files.autoSave": "onFocusChange",
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"powershell.codeFolding.showLastLine": false,
"powershell.codeFormatting.preset": "OTBS",
"powershell.codeFormatting.autoCorrectAliases": true,
"powershell.codeFormatting.useCorrectCasing": true,
"powershell.codeFormatting.openBraceOnSameLine": true,
"powershell.codeFormatting.newLineAfterOpenBrace": true,
"powershell.codeFormatting.newLineAfterCloseBrace": true,
"powershell.codeFormatting.whitespaceAroundOperator": true,
"powershell.codeFormatting.whitespaceAfterSeparator": true,
"search.showLineNumbers": true,
"search.smartCase": true,
"editor.foldingStrategy": "indentation",
"workbench.sideBar.location": "right",
"window.menuBarVisibility": "compact",

I do however recommend you go through the Settings in the visual editor, that way you’ll get a much better understanding of what a setting means.

Conclusion

As you have learned by now the flexibility of VSCode can be both a blessing and a curse due to the huge amount of options you have, but I hope that with this article I have given you some ideas on improving your own setup. Please note that this setup is based on my personal preference, if you want to change things up, please do! Thoughts? Tips? Leave them in the comments below!

Leave a Reply

Your email address will not be published. Required fields are marked *