如何阻止VSCode自动创建.vscode/settings.json等工作区文件?
Absolutely, you can stop VS Code from automatically generating the .vscode directory and empty settings.json file when you open settings in a new folder. Here's how to lock into using only your global (user) settings:
Method 1: Set Default Settings Scope to Global
This makes VS Code load your global settings by default whenever you hit ⌘+, (or Ctrl+, on Windows/Linux), so it won’t trigger the creation of local workspace settings:
- Open your global settings: Press
⌘+,to launch the settings UI, then click theOpen Settings (JSON)icon (the curly braces{}) in the top-right corner. This opens your user-levelsettings.json. - Add this line to the JSON object:
"workbench.settings.defaultSettingsScope": "user" - Save the file. Now whenever you open settings in a new folder, it’ll pull up your global configuration instead of trying to create a local workspace settings file.
Method 2: Fully Disable Local Workspace Settings
If you want to block any local workspace settings from being created at all—even if you intentionally try to access them—add this to your global settings.json:
"workbench.settings.enableLocalSettings": false
With this enabled, VS Code will ignore all attempts to use project-specific settings and always rely on your global setup.
Quick Notes:
- Double-check you’re editing the user/global
settings.json, not a workspace-specific one. You can confirm via the file path: it lives in your user profile (e.g.,~/Library/Application Support/Code/User/settings.jsonon macOS,%APPDATA%\Code\User\settings.jsonon Windows). - If you ever need project-specific settings later, you can temporarily revert these configs or manually create the
.vscode/settings.jsonfile for that folder.
内容的提问来源于stack exchange,提问作者Rodolfo Carvalho

