Visual Studio Code is my default PowerShell script editor. It is free and available in Windows, macOS, and Linux.
By default, it uses text as the script language when a new file is opened. To make it recognize the PowerShell cmdlet, I have to manually change the language mode (press F1, type Change Language Mode, then select PowerShell form the list of the language) or first save to the file to ps1. This becomes inconvenience overtime.
Luckily, a new setting “files.defaultLanguage” is added. I didn’t backtrack when this setting was added. It’s available in the current release 1.14.0 as of this writing.
To configure the default language setting,
- Open File, Preferences, Settings
- Add the following to set PowerShell as the default language mode
- “files.defaultLanguage": "powershell",
- Save the setting.json file
To set other supported languages as the default
- Delete “powershell” in the line
- Press Ctrl + Spacebar to select the option from the list