Skip to main content

Sharing Project Settings in VS Code

Inbox

  • 📺 VS Code Workspace Settings • 4 minute video by Sana Ajani showing how to use VS Code’s workspace settings to customize the editor for a specific project
  • By adding a .vscode/settings.json file to your project, you can customize VS Code’s settings for that project
  • Workspace settings will override user settings
  • Useful for allowing users to have different settings for different projects
  • Allows users to each have different preferred settings while still sharing the same project settings when collaborating on a project
  • For example, a user may generally prefer to use Black as their Python formatter, but a project may require using YAPF instead. In that case, the project could include a .vscode/settings.json file with the following contents:
{
  "python.formatting.provider": "yapf"
}
  • That way, when the user opens the project in VS Code, it will automatically use YAPF to format Python files in that project, but will continue to use Black for all other projects
  • VS Code Workspace settings docs: https://code.visualstudio.com/docs/getstarted/settings#_workspace-settings
  • This is a great way to document project-specific settings that are required for the project to work properly and avoid having to remember to manually configure them every time you open the project
  • If your onboarding checklist currently includes a step like “Install the Prettier extension and enable it for this project”, you can replace that step with a .vscode/settings.json file that includes the following instead:
{
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode"
}
  • Save time and discussion and automate all the things! 🤖
  • By committing these settings to the project, you can ensure that everyone who opens the project in VS Code will have the same settings applied
  • What happens if a setting requires and extension the user hasn’t installed?
    • The user will be prompted to install the extension
    • What does that prompt look like?
  • Another example is that in my website repo, I like to exclude the src/content git submodule from the file explorer and all search results to avoid accidentally editing those files or having them clutter up searches for text or files. So, I have the following in that project’s .vscode/settings.json file:
{
  "files.exclude": {
    "src/content": true
  }
}

Inbox