For each project (with Git enabled), VSCode auto generate a project specific config file called .vscode.
How to disable this behavior?
Maybe some extention is doing it? It shouldn't create folder unless workspace settings were changed or created runner or tasks or debug.
Look what's inside that settings.json file.
Try to run vscode without extentions.
You can also exclude it from explorer:
setting.json (ctrl+,) >>
"files.exclude": {
"**/.vscode": true,
},
Related
I've recently tried running my Python project in VSCode.
I have in my code imports from other files withing my project. The problem is that when I try running it from the default "play button"/"run in terminal" option, it does not detect my other files. (I opened the entire project's folder, as well as created a workspace with it))
When I created a debug configuration, this line was added automatically:
"env": {"PYTHONPATH": "${workspaceRoot}"}
which enabled the requested import.
I was still not able to figure how to make it work with the default "play button". (e.g see what run configuration it uses, etc)
Thanks for your help! <3
The fix was adding:
"terminal.integrated.env.windows": {"PYTHONPATH": "${workspaceFolder}"}
to settings.json and restarting VSCode
The launch.json file should be inside the .vscode folder, but it is not present there.
How can I get this file so that I can modify the configurations?
As described in the Launch Configurations section of the Visual Studio Code documentation:
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.
To create a launch.json file, click the create a launch.json file link
in the Run start view.
As of Visual Studio Code 1.56:
Once that's created, it should now be available under your workspace's .vscode folder.
Click on the debug side bar to open the debugging options. Then either the cog icon at the top, or the create a launch.json file link below the big blue button. If the launch.json file is present, it will open it otherwise it will generate one.
Warning: if you try to create an empty one (or one with an invalid content), trying to get to that file through the "Create a launch.json file" would not do anything.
See issue 133327.
That will be fixed with VSCode 1.61 (Sept. 2021): at least, that existing file will be opened when you click on "Create a launch.json file".
We are developing a new vscode extension, currently all workspace configuration contributed are kept in settings.json file in .vscode directory. We would like to keep all the configuration(settings) related to the new extension in a separate file in .vscode directory.
Is there way to do this?
All features that vscode settings page provides, should also be supported, like auto-suggestions of configuration keys, setting form etc.
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.
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.
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.
Working on a Python project and I want to define the path to where I store my virtualenv for the project.
I have linting settings in my .vscode/settings.json workspace settings, however this is checked into my git repository and is common across any collaborators on the project, thus I don't think it would make sense to reference where I personally keep my virtualenv for this project in the workspace settings.
As it is a project-specific virtualenv, it does not make sense to reference it in my user settings either.
Is there a way I can store my path to my virtualenv for this project?
You can override .vscode/settings.json with settings in code-workspace.json, but more general and flexible overriding does not seem to be possible - I recommend voting for Add ability to extend from other settings files. If you commit both .vscode/settings.json and [name].code-workspace, then it seems like it'll be difficult for team members to customize their settings.
Nested settings in .vscode/settings.json seem to override [name].code-workspace settings, so you could try committing a workspace file. Some people also commit example files, e.g. settings.json.default and instruct team members to remove the default extension.
I messed around with an example:
example.code-workspace
{
"folders": [
{
"path": "."
},
{
"path": "nested"
}
],
"settings": {
"window.zoomLevel": 1,
"editor.fontSize": 8
}
}
With nested containing .vscode/settings.json:
{
"window.zoomLevel": 2,
"editor.fontSize": 16
}
This works as you'd probably expect: the nested folder settings override the workspace settings, although window.zoomLevel became disabled with a tooltip message saying that it would only be applied if opened directly.
This should be possible if you're keeping the virtualenv in the same folder as the project code itself. Then you can use the following setting in .vscode/settings.json:
"python.venvPath": "${workspaceRoot}/venv"
Just exclude venv from your SCM and you're done.
If you prefer to keep the virtualenv elsewhere, this can be solved by symlinking the location to venv inside the workspace root.