5

How do I set my workspace folder in Visual Studio Code?

This appears to be necessary for debugging, and I suspect it's why my breakpoints aren't getting hit.


Further reading:

  1. This question about adding workspaces doesn't have an accepted answer.
  2. What is a 'workspace' in VS Code?, while providing a wealth of information, does not explain how to set a workspace for debugging.
  3. User and Workspace Settings. The documentation also does not mention how to set a workspace for debugging.
Super Jade
  • 5,609
  • 7
  • 39
  • 61

2 Answers2

4

How do I set my workspace folder in Visual Studio Code?


  1. Open Visual Studio Code. You should be on the Welcome page.
  2. Add workspace folder...

Add workspace folder link

  1. File explorer opens. Select the folder you want for your workspace. Add.


Now your workspace folder is shown in the left pane :-)

workspace folder

Super Jade
  • 5,609
  • 7
  • 39
  • 61
  • Can we launch a workspace from the command line? e.g. `code ./hello-world.code-workspace` – Joey Gough Jul 11 '20 at 11:51
  • After reviewing the [docs](https://code.visualstudio.com/docs/) > User Guide > Command Line and Multi-Root Workspaces, I found nothing. Maybe there is a round-about way... – Super Jade Jul 11 '20 at 23:40
  • If there are more than one workspace folder, does it take the first one? I think I have to move the folder I want to the iop. – Timo Mar 22 '21 at 20:35
1

Create a launch.json and set your workspace in "cwd"

    {
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config:python.pythonPath}",
            "program": "${file}",
            "cwd": "*your/new/workspace/*",
            "env": {},
            "envFile": "${workspaceFolder}/.env",
            "debugOptions": [
                "RedirectOutput"
            ]
        }
    ]
}
Alex
  • 11
  • 1