How to Set Workspace Settings in VS Code
In Visual Studio Code, you can customize your development environment
on a project-by-project basis using workspace-specific settings. This
article provides a straightforward guide on how to configure these
settings using both the graphical Settings editor and by directly
editing the settings.json file, ensuring your project team
shares the exact same editor configurations.
What are Workspace Settings?
Workspace settings are configuration rules that apply only to the
specific project folder or workspace you currently have open. These
settings override your global “User” settings and are stored inside a
.vscode folder at the root of your project directory. This
makes it easy to commit these settings to version control (like Git) so
everyone working on the project has the same setup.
Method 1: Using the Settings UI
The easiest way to define workspace settings is through the built-in graphical interface:
- Open your project folder in Visual Studio Code.
- Open the Settings menu by pressing
Ctrl + ,(Windows/Linux) orCmd + ,(macOS). Alternatively, go to File > Preferences > Settings (or Code > Settings on macOS). - At the top of the Settings editor, click on the Workspace tab.
- Browse or search for the setting you want to change (for example, “Format On Save”).
- Modify the setting. VS Code will automatically create a
.vscode/settings.jsonfile in your project root and save your changes there.
Method 2: Editing settings.json Directly
If you prefer to write configuration code directly, you can create or edit the JSON file manually:
- In the file explorer of your project, create a new folder named
.vscodeat the root level if it does not already exist. - Inside the
.vscodefolder, create a file namedsettings.json. - Open
settings.jsonand add your configuration settings in JSON format.
Here is an example of what your .vscode/settings.json
file might look like:
{
"editor.tabSize": 2,
"editor.formatOnSave": true,
"files.exclude": {
"**/.git": true,
"**/node_modules": true
}
}Once saved, these settings will instantly apply to the current workspace and will not affect any of your other VS Code projects.