3

I keep setting up the same launch.json file per project. But I would like to change the default one so it's already got the launch targets configured.

Can I change the default one, or is it possible to create a user one? I'm using it on Mac OS X.

starball
  • 20,030
  • 7
  • 43
  • 238
Richard G
  • 5,243
  • 11
  • 53
  • 95
  • As far as I know, initial configuration settings for launch.json are kept in extension (in package.json or somewhere else) and generated automatically when you create project, you can change it manually but all changes will lost after upgrading extension. – Bob Mar 29 '17 at 16:14
  • 1
    ok no worries not a big deal - would be great to have a template project option though because for every project I pretty much copy and paste about 10 files. – Richard G Mar 30 '17 at 11:38
  • 1
    'launch.json' is generated by a template provided by the debugger that you have selected for the project. It is not tied to package.json at all since vscode supports more than javascript. – Gorkem Ercan Mar 30 '17 at 17:03
  • @Gorkem Ercan: Isn't it always a JSON file, JavaScript or not? – Peter Mortensen Nov 19 '20 at 03:38
  • Correct, regardless of the language it is launch.json. Depending on the language/debugger the properties of configuration may change – Gorkem Ercan Nov 20 '20 at 07:27
  • related: [How can I set a default tasks.json file for Visual Studio Code?](https://stackoverflow.com/q/76141850/11107541) – starball May 16 '23 at 21:51

1 Answers1

0

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.

starball
  • 20,030
  • 7
  • 43
  • 238