Customize Visual Studio Code settings for PowerShell development

This post is continuation of series of PowerShell development using Visual Studio code. In this blog post, we’ll see how to customize Visual Studio code for PowerShell development. One of the great features of Visual Studio Code is the extent to which you can customize it. Each extension usually provides customizable settings, too. To begin to customize Visual Studio Code, select the Command Palette from the View menu, or press Ctrl+Shift+P (Cmd + P on the Mac), type user, and then select Preferences: Open User Settings.  This will open two editor windows as shown in the following screenshot: 

Editing user settings in VS code
Editing user settings in VS code

The settings.json file shown in the center pane is read-only. You need to select a setting of your choice and then copy it over to User Settings / WorkSpace settings files to edit it. This should also be clear from the below screenshot:

Editing user settings in VS code - 02
Editing user settings in VS code – 02

The PowerShell extension comes with below basic settings to edit:

Customization settings available in PowerShell extension
Customization settings available in PowerShell extension

Below is a basic set of customization, one would recommend:

// Place your settings in this file to overwrite the default settings
{

"editor.rulers": [ 120 ],

"files.trimTrailingWhitespace": true,

"terminal.integrated.shell.windows":
"C:\\WINDOWS\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"

}

The editor ruler provides a visual reminder of where you might want to wrap your PowerShell script. The trimTrailingWhitespace setting is particularly convenient for PowerShell. Finally, you will likely want Visual Studio Code’s Integrated Terminal to open PowerShell instead of CMD.exe. For 64 bit versions of Operating system, one should use C:\Windows\sysnative instead of using C:\Windows\system32 as path.

You can get more in-depth coverage of user settings in the User and Workspace Settings article in the Visual Studio Code docs.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s