'How do I set the default launch.json and tasks.json for debugging my C/C++ applications in VS Code

I have set up my launch.jason and tasks.json files for VS Code, and can debug my applications using that. The problem is whenever I create a new application, I have to find the files from one of my old apps and copy paste them to the new application folder. And if I delete these .json files, I have no option but to rewrite them again which is pretty inconvenient.

Is there a way to set these files as the default ones for all C/C++ projects? So whenever I create a new project, VS Code automatically loads these files?



Solution 1:[1]

While I have never done this myself, the VS Code docs seem to suggest that you can have launch setting which are scoped outside of your project:

VS Code keeps debugging configuration information in a launch.json file located in a .vscode folder in your workspace (project root folder) or in your user settings or workspace settings.

The docs also seem to suggest that VS Code might have a mechanism for wider scoped tasks through a "Task Provider":

Workspace or folder specific tasks are configured from the tasks.json file in the .vscode folder for a workspace.

Extensions can also contribute tasks using a Task Provider, and these contributed tasks can add workspace-specific configurations defined in the tasks.json file.

I realise an answer from someone who has actually used these features would be preferable, but I thought I'd point them out nonetheless.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cascades