jsonvisual-studio-code

Can I have a "settings.json" file on a per-project basis?


Given:
I have (want to have) multiple projects in Visual Studio Code that might have multiple targets and multiple settings.json files.

Example:
I have a workspace/project where I am writing remotely executed Python code for my Raspberry Pi based robot and it has the following settings.json file.

{
    "telemetry.enableTelemetry": false,
    "git.confirmSync": false,
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "python.autoComplete.addBrackets": true,
    "python.analysis.disabled": [
        "unresolved-import"
    ],
    "projectManager.git.baseFolders": [
        "C:\\Users\\Jim\\GoPiGo_Projects\\New_Remote_Camera_Robot",
        "C:\\Users\\Jim\\GoPiGo_Projects\\Setup_and_Configuration"
    ],
    "files.eol": "\n",
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "remote.SSH.showLoginTerminal": true,
    "remote.SSH.remotePlatform": {
        "Charlie-Wireless": "linux",
        "Raspbian-Legacy": "linux"
    },
    "liquid.rules": {

        "ignore": [
            {
                "type": "liquid",
                "begin": "comment",
                "end": "endcomment"
            },
            {
                "type": "html",
                "begin": "script",
                "end": "script"
            },
            {
                "type": "html",
                "begin": "style",
                "end": "style"
            }
        ],
        "html": {
            "correct": false,
            "force_attribute": false,
            "braces": false,
            "preserve": 2,
            "unformatted": false
        },
        "js": {
            "preserve": 1,
            "method_chain": 0,
            "quote_convert": "none",
            "format_array": "indent",
            "format_object": "indent",
            "braces": false,
            "no_semicolon": false,
            "brace_block": true
        },
        "scss": {
            "css_insert_lines": true,
            "preserve": 2,
            "braces": false,
            "brace_block": true
        },
        "css": {
            "css_insert_lines": true,
            "preserve": 2,
            "braces": false,
            "brace_block": true
        },
        "json": {
            "preserve": 0,
            "braces": false,
            "brace_block": true,
            "no_semicolon": true
        }
    },
    "html.format.endWithNewline": true,
    "python.analysis.completeFunctionParens": true,
    "editor.renderWhitespace": "all",
    "telemetry.telemetryLevel": "error",
    "workbench.editor.highlightModifiedTabs": true,
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.detectIndentation": false,
    "git.inputValidationLength": 100,
    "files.autoSave": "onWindowChange",
    "gitlens.gitCommands.skipConfirmations": [
        "fetch:command",
        "stash-push:command",
        "switch:command",
        "tag-create:command",
        "push:command",
        "branch-create:command"
    ],
    "terminal.integrated.scrollback": 100000,
    "workbench.colorTheme": "Night Owl",
    "diffEditor.ignoreTrimWhitespace": false,
    "editor.autoClosingQuotes": "never",
    "editor.autoClosingOvertype": "never",
    "editor.autoClosingDelete": "never",
    "editor.autoSurround": "never",
    "editor.accessibilitySupport": "off",
    "editor.autoClosingBrackets": "never",
    "gitlens.defaultDateFormat": null
}

I have created, (am creating), another project in another workspace that contains a C++ file that creates a Windows native .exe "checklist" program. It has the following settings.json file.

{
    "git.confirmSync": false,
    "git.autofetch": true
}

The settings.json file appears to be located within the "C:\Users\Flight Simulator\AppData\Roaming\Code\user\sync\settings [\preview?] directory.

When VS Code goes to "sync settings" it complains that there are "conflicts" that I must resolve and/or merge.

Obviously the settings for a Python project on a Raspberry Pi will be vastly different from the settings for a C++ native Windows app.

How do I allow each individual project to have settings that are unique to that project?


Solution

  • If by project you mean an opened folder or repository, then just put different .vscode/settings.json inside of each project and that should be it