One of my frustrations with VisualStudio Code was creating a launch.json
file whenever I wanted to debug a one-off Python file.
Today, I learned that you could add a debugger configuration to your user settings. This allows you always to have a debugging configuration available.
How to do this
Create a debugging (or launch) configuration:
- Select the “Run and Debug” tab and click “create a launch.json file”
2. Choose “Python File”
3. VS Code will generate a configuration for you. This is the one I used, where I changed the "justMyCode"
to false
, so I can step in to any Python code.
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
}
4. Copy the config (including the curly braces)
5. Open your user configuration ( ⌘
/ Ctrl
+ ,
) and search for “launch”.
6. Click “Edit in settings.json”
7. Add your configuration to the "configurations"
list.
This is what mine looks like, for reference:
...
"launch": {
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
}
],
"compounds": []
}