Skip to content

Instantly share code, notes, and snippets.

@ninmonkey
Last active March 23, 2023 03:47
Show Gist options
  • Select an option

  • Save ninmonkey/065c5b1b2935c59f728e1162996596fb to your computer and use it in GitHub Desktop.

Select an option

Save ninmonkey/065c5b1b2935c59f728e1162996596fb to your computer and use it in GitHub Desktop.
VS Code Settings for Powershell 2023.03

Default settings in VS Code are dynamic. They are generated based on your extensions's metadata. That means they are up to date. I have some tips for discovering new settings in Vs Code through Default settings (ninmonkeys.com)

Another extension that helps is Better Align

The main settings:

{   "powershell.codeFormatting.autoCorrectAliases": true,
    "powershell.codeFormatting.useConstantStrings": true,
    "powershell.codeFormatting.useCorrectCasing": true,
    "powershell.codeFormatting.alignPropertyValuePairs": true,
    
    // if you want custom rules
    // "powershell.scriptAnalysis.settingsPath": "C:/dotfiles/pwsh/PSScriptAnalyzerSettings.psd1",
}

img

To get schemas, and validation on Type.ps1xml and Format.ps1xml files, use: the extension redhat.vscode-xml with this config

    "xml.fileAssociations": [
        {
            "systemId": "https://raw.githubusercontent.com/PowerShell/PowerShell/master/src/Schemas/Format.xsd",
            // "pattern": "**/*.Format.ps1xml"
            "pattern": "**/*.[Ff]ormat.ps1xml"
        },
        {
            "systemId": "https://raw.githubusercontent.com/PowerShell/PowerShell/master/src/Schemas/Types.xsd",
            "pattern": "**/*.[tT]ypes.ps1xml"
        }
    ],

Format on save by default

 "[json][jsonc][markdown][powershell]": {
        "editor.fontSize": 13,
        "editor.formatOnSave": true,
        "editor.formatOnPaste": false,
        // "editor.semanticHighlighting.enabled": true,
    },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment