VSCode: How do I find what my workspace folder is

后端 未结 2 1594
误落风尘
误落风尘 2021-01-14 03:05

Is there a simple command that will tell me what my workspace folder is? I tried ${workspaceFolder} in the terminal but that didn\'t work.

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-14 03:16

    VSCode 1.52 (Nov. 2020) will simplify that use case.

    Before:

    /ws
       /.vscode
            launch.json
    /proj_a
       /scr
    /proj_b
       /scr
    /proj_c
       /scr
    /proj_d
       /scr
    

    Where /ws and /proj_* are all folders added to create the multi folder workspace. But ${workspaceFolder} always is /ws

    ${workspaceFolder:proj_a} is possible but not convenient, when you have a debug configuration in /ws/.vscode/launch.json that uses ${file} and you want to be able to use this configuration on all files in your multi-root setup.
    And in order to establish the correct working directory for your debuggee you need a way to derive the workspace folder path from ${file}.

    Introducing ${fileWorkspaceFolder}.

    With VSCode 1.52, see:

    • issue 84162: "Get the workspace folder of the current file "
    • issue 108907: "Multi root workspace - Variable for the current file's workspace directory"
    • commit 876d1f0: introduce new variable ${fileWorkspaceFolder}

    That will complement the Predefined variables examples.

提交回复
热议问题