Intro

This is just a quick post to share something that I found which is a really nice quality of life tip for VSCode.

In this post, I will show you how to configure per-language settings in VSCode so that, in Python files you can set to indent with 4 spaces and in Javascript you can set to indent with 2 spaces.

Software

The following software was used in this post.

  • VSCode - 1.65.2

How?

Open the command pallete with the CMD + SHIFT + p keyboard combination and type Preferences: Open Settings (JSON) and hit ENTER .

For each language, add a stanza in the format "[language]": {} . For example:

settings.json
"[rust]": {
    "editor.tabSize": 4,
},
"[python]": {
    "editor.tabSize": 4,
},
"[njk]": {
    "editor.formatOnSave": false
},

My entire config loooks like the below.

settings.json
{
    "editor.fontFamily": "'FiraCode NF','FiraCode Nerd Font Mono',Consolas, 'Courier New', monospace",
    "files.associations": {
        "*.njk": "njk"
    },
    "emmet.includeLanguages": {
        "njk": "html"
    },
    "remote.SSH.remotePlatform": {
        "dev01": "linux"
    },
    "terminal.integrated.fontFamily": "'FiraCode NF','FiraCode Nerd Font Mono',Consolas, 'Courier New', monospace",
    "editor.suggestSelection": "first",
    "workbench.colorTheme": "Material Deep Ocean",
    "workbench.startupEditor": "none",
    "remote.SSH.remoteServerListenOnSocket": true,
    "terminal.integrated.fontSize": 14,
    "editor.fontSize": 14,
    "editor.accessibilitySupport": "off",
    "security.workspace.trust.untrustedFiles": "open",
    "editor.wordWrapColumn": 100,
    "editor.tabSize": 2,
    "editor.formatOnSave": true,
    "rust-analyzer.checkOnSave.command": "clippy",
    "[rust]": {
        "editor.tabSize": 4,
    },
    "[python]": {
        "editor.tabSize": 4,
    },
    "[njk]": {
        "editor.formatOnSave": false
    },
}

Outro

And that's it! Go forth and conquer my friends.

# vscode