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:

  1. Open your project folder in Visual Studio Code.
  2. Open the Settings menu by pressing Ctrl + , (Windows/Linux) or Cmd + , (macOS). Alternatively, go to File > Preferences > Settings (or Code > Settings on macOS).
  3. At the top of the Settings editor, click on the Workspace tab.
  4. Browse or search for the setting you want to change (for example, “Format On Save”).
  5. Modify the setting. VS Code will automatically create a .vscode/settings.json file 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:

  1. In the file explorer of your project, create a new folder named .vscode at the root level if it does not already exist.
  2. Inside the .vscode folder, create a file named settings.json.
  3. Open settings.json and 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.