Custom workspace settings in VS code

Work on a Python project, and I want to determine the path to where I store my virtualenv for the project.

I have linting settings in my workspace settings .vscode/settings.json , however this is checked in my git repository and is common for all project co-authors, so I donโ€™t think it would be advisable to refer to where I personally save my virtualenv for this project in the workspace settings.

Since this is a virtual virtual project, it does not make sense to refer to it in my user settings.

Is there a way to keep my path to my virtualenv for this project?

+8
visual-studio-code
source share
2 answers

This should be possible if you save 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 venv done.

If you prefer to keep the virtual environment elsewhere, this can be solved by matching the location with venv inside the root of the workspace.

0
source share

You can override .vscode/settings.json with the settings in code-workspace.json , but a more general and flexible redefinition is not possible - I recommend that you vote for the Add extension option from other settings files . If you .vscode/settings.json both .vscode/settings.json and [name].code-workspace , it seems that it will be difficult for team members to customize their settings.

The nested settings in .vscode/settings.json seem to override the [name].code-workspace parameters, so you can try to execute the workspace file. Some people also submit example files, for example. settings.json.default and ask team members to remove the default extension.

I messed up the example: example.code-workspace

 { "folders": [ { "path": "." }, { "path": "nested" } ], "settings": { "window.zoomLevel": 1, "editor.fontSize": 8 } } 

With the attached content .vscode/settings.json :

 { "window.zoomLevel": 2, "editor.fontSize": 16 } 

This works as you probably expect: subfolder settings override workspace settings, although window.zoomLevel has been disabled by a tooltip saying that it will only be applied when it opens directly.

0
source share

All Articles