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.

- 4,759
- 14
- 54
- 76
-
Do you need that for further CLI processing or just to see it? – ford04 Aug 06 '19 at 14:16
-
Just to see it. – jss367 Aug 06 '19 at 14:19
-
See https://stackoverflow.com/questions/53485115/how-to-display-current-values-of-vs-codes-predefined-variables-such-as-work/53486166#53486166 – Mark Aug 06 '19 at 14:34
2 Answers
Alternatives that currently come to my mind:
1.) If you want to see the workspace folder in the titlebar, you could adjust window.title
setting (workspace or user settings):
"window.title": "${dirty}${activeEditorShort}${separator}${folderPath}${separator}${appName}"
Multiple variables can be used here - see Defaults -> window.title. ${folderPath}
works best for me, if you prefer the absolute workspace path.
2.) Define a task that can print your workspace folder at the terminal:
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "echo ${workspaceFolder}"
}
]
3.) File -> save as workspace
should actually show the current workspace folder (seems to be not consistent with Windows/Mac though)
4.) Just open the terminal and look at your cwd
. I am not sure, if all terminals default to the workspace folder.

- 66,267
- 20
- 199
- 171
-
The first method works. Regarding the third, I'm on a Mac and I have "Save As..." and "Save Workspace As..." but neither of these show the current workspace folder when I select them. – jss367 Aug 06 '19 at 14:37
-
OK, good hint. I am on windows, does seem to work there. 4.) possibility would be to just open terminal and see the cwd. I am not sure, if that fits for all terminals, but I'll add it with reservation. – ford04 Aug 06 '19 at 14:48
-
1workspaceRoot still works for now but it was deprecated long ago, see https://github.com/Microsoft/vscode-recipes/commit/797ca8054fe7e9b3bf812d2b366631e12c11b90e and no mention of it in https://code.visualstudio.com/docs/editor/variables-reference. Don't use `workspaceRoot`. – Mark Aug 06 '19 at 14:53
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.

- 1,262,500
- 529
- 4,410
- 5,250