Is it possible to have a global launch.json file?
Asked Answered
S

2

16

I am using Don Jayamanne's Python extension and it is working well. The only issue I have is for every project I work on, I have to copy the \.vscode\launch.json file. I was wondering if there is a way to place that file somewhere globally so the settings are applied to all my projects. Something similar to how the global settings.json works for user settings.

In other words I am looking for a way to avoid having to copy \.vscode\launch.json to every folder I store and write python code in.

Stets answered 26/4, 2016 at 14:32 Comment(0)
R
31

Yes, it is possible - you need to put the requisite launch config directly in your user settings file, as described here.

From the linked page:

... currently it is not possible to have one global launch.json file which would be used everywhere, but what works is to add a "launch" object inside your user settings (preferences > user settings). This way it will be shared across all your workspaces
Example:

"launch": {
    "version": "0.2.0",
    "configurations": [
        {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "program": "${file}",
        "cwd": "${workspaceRoot}",
        "runtimeExecutable": "/usr/local/bin/node"
        }
    ]
}
Rotow answered 28/1, 2017 at 21:53 Comment(2)
Thank you. This worked. All you have to do is paste your "launch" settings into your user settings file (settings.json).Stets
its is not working now maybe they did some changes (for inputs)Metalloid
C
1

See https://code.visualstudio.com/docs/editor/debugging#_global-launch-configuration.

VS Code supports adding a "launch" object inside your User settings. This "launch" configuration will then be shared across your workspaces. For example:

"launch": {
    "version": "0.2.0",
    "configurations": [{
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "program": "${file}"
    }]
}

Historical note: According to other writings, in certain older versions of VS Code, if your workspace had its own .vscode/launch.json, the global launch configs would be ignored, but it seems that this is no longer true in the latest versions (I tried on 1.78) for the user settings.json. It is still true that the workspace settings.json's launch property will be ignored if you have a launch.json file in your workspace.

https://code.visualstudio.com/docs/editor/variables-reference will probably also be useful to you.

Conversation answered 13/11, 2023 at 8:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.