π§ VSCode settings.json Cheat Sheet #
π Overview #
VSCode settings.json files control editor behavior through JSON configuration. There are two types:
- User Settings: Global settings that apply to all VSCode instances
- Workspace Settings: Project-specific settings that override user settings
π File Locations #
User Settings #
- Windows:
%APPDATA%\Code\User\settings.json - macOS:
$HOME/Library/Application Support/Code/User/settings.json - Linux:
$HOME/.config/Code/User/settings.json
Workspace Settings #
- Location:
.vscode/settings.jsonin your project root - Purpose: Share project-specific settings via version control
- Priority: Overrides user settings for that workspace
π― Accessing Settings #
Command Palette (Ctrl+Shift+P) #
Preferences: Open User Settings (JSON)
Preferences: Open Workspace Settings (JSON)
Preferences: Open Settings (UI)
Keyboard Shortcuts #
- Settings UI:
Ctrl+,(Cmd+, on Mac) - Direct JSON: Use command palette
Settings URL Navigation #
vscode://settings/<settingName>
Example: vscode://settings/workbench.colorTheme
π« files.exclude - The Complete Guide #
β οΈ Critical Limitation #
VSCode’s files.exclude does NOT reliably support false values as exceptions to broad true patterns.
β This DOESN’T work reliably:
{
"files.exclude": {
"**/.*": true, // Hide all hidden files
"**/.vscode": false, // Exception - IGNORED!
"**/.env": false // Exception - IGNORED!
}
}
β Recommended Approach: Explicit Patterns #
Instead of broad exclusions with exceptions, explicitly list what you want to hide:
{
"files.exclude": {
// Development artifacts
"**/node_modules": true,
"**/.next": true,
"**/.nuxt": true,
"**/.svelte-kit": true,
"**/.astro": true,
"**/.turbo": true,
"**/dist": true,
"**/build": true,
// Python artifacts
"**/__pycache__": true,
"**/.pytest_cache": true,
"**/.mypy_cache": true,
"**/.coverage": true,
"**/.tox": true,
"**/*.pyc": true,
// Version control & IDE
"**/.git": true,
"**/.idea": true,
"**/.vscode-server": true,
"**/.history": true,
// System files
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/*.tmp": true,
"**/*.temp": true,
// Cache & logs
"**/.cache": true,
"**/.npm": true,
"**/.yarn": true,
"**/*.log": true,
"**/*.pid": true,
// Shell history
"**/.bash_history": true,
"**/.zsh_history": true,
"**/.lesshst": true,
"**/.wget-hsts": true
}
}
π Alternative: Using .gitignore #
Enable VSCode to respect .gitignore patterns:
{
"explorer.excludeGitIgnore": true,
"files.exclude": {}
}
Then create a .gitignore file with negation patterns:
# Hide all hidden files
.*
# Show specific ones
!.vscode
!.windsurf
!.env*
!.venv
π search.exclude vs files.exclude #
files.exclude #
- Hides files from File Explorer
- Files remain searchable by default
- Affects file tree visibility
search.exclude #
- Excludes files from search results
- Files remain visible in explorer
- Inherits from
files.excludeby default
{
"files.exclude": {
"**/node_modules": true
},
"search.exclude": {
"**/build": true,
"**/logs": true
}
}
π Glob Pattern Syntax #
VSCode uses standard glob patterns:
| Pattern | Matches | Example |
|---|---|---|
* |
Any characters in path segment | *.js β app.js |
** |
Any number of path segments | **/test β src/test, lib/unit/test |
? |
Single character | file?.txt β file1.txt |
{} |
Group conditions | **/*.{js,ts} β JS and TS files |
[] |
Character range | file[0-9].txt β file1.txt |
[!] |
Negated range | file[!0-9].txt β filea.txt |
Common Patterns #
{
"files.exclude": {
// Exact folder name anywhere
"**/node_modules": true,
// Files with extension
"**/*.log": true,
// Multiple extensions
"**/*.{tmp,temp,cache}": true,
// Prefix patterns
"**/temp*": true,
// Nested paths
"**/src/generated/**": true
}
}
π¨ Common Settings Examples #
Basic Development Setup #
{
"editor.fontSize": 14,
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.wordWrap": "on",
"editor.minimap.enabled": false,
"workbench.colorTheme": "Dark+ (default dark)",
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000
}
Language-Specific Settings #
{
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.tabSize": 4
},
"[markdown]": {
"editor.wordWrap": "on",
"editor.quickSuggestions": false
}
}
Project-Specific Workspace Settings #
{
"python.defaultInterpreterPath": "./.venv/bin/python",
"python.terminal.activateEnvironment": true,
"files.exclude": {
"**/__pycache__": true,
"**/node_modules": true,
"**/.pytest_cache": true
},
"search.exclude": {
"**/build": true,
"**/dist": true
}
}
π Security & Performance #
Exclude Sensitive Files #
{
"files.exclude": {
"**/.env": true,
"**/.env.local": true,
"**/secrets.json": true,
"**/*.key": true,
"**/*.pem": true
}
}
Performance Optimization #
{
"files.exclude": {
"**/node_modules": true,
"**/.git": true,
"**/build": true,
"**/dist": true,
"**/*.log": true
},
"search.exclude": {
"**/node_modules": true,
"**/build": true,
"**/coverage": true
},
"files.watcherExclude": {
"**/node_modules/**": true,
"**/.git/objects/**": true,
"**/build/**": true
}
}
π οΈ Best Practices #
β Do #
- Use workspace settings for project-specific configurations
- Explicitly list patterns instead of broad exclusions with exceptions
- Test settings in a sample project before applying globally
- Use meaningful comments in your settings.json
- Version control workspace settings for team consistency
β Don’t #
- Rely on
falseoverrides infiles.exclude(they don’t work reliably) - Put sensitive information directly in settings files
- Use overly broad patterns that might hide important files
- Mix user and workspace settings for the same purpose
- Forget to test exclusion patterns thoroughly
π§ Troubleshooting #
Settings Not Working? #
- Check JSON syntax - Use VSCode’s JSON validation
- Reload window -
Ctrl+Shift+Pβ “Developer: Reload Window” - Check setting precedence - Workspace overrides user settings
- Verify glob patterns - Test with simple patterns first
Files Still Showing? #
- Clear editor history - May cache old file lists
- Check multiple exclusion settings -
files.exclude,search.exclude, etc. - Restart VSCode - Sometimes required for complex changes
- Use explicit patterns - Avoid relying on false overrides
π Advanced Tips #
Settings Sync #
Enable settings sync across devices:
{
"settingsSync.keybindingsPerPlatform": false
}
Conditional Settings #
Use different settings per OS in workspace:
{
"terminal.integrated.shell.windows": "powershell.exe",
"terminal.integrated.shell.osx": "/bin/zsh",
"terminal.integrated.shell.linux": "/bin/bash"
}
Extension-Specific Settings #
{
"eslint.workingDirectories": ["./frontend", "./backend"],
"prettier.configPath": "./.prettierrc.json",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true
}
π Related Settings #
File Association #
{
"files.associations": {
"*.env.*": "properties",
"Dockerfile.*": "dockerfile",
"*.config.js": "javascript"
}
}
Auto-Save & Formatting #
{
"files.autoSave": "onFocusChange",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll.eslint": true
}
}
π‘ Pro Tip: Always test your exclusion patterns in a sample project first. The files.exclude behavior can be subtle, and it’s better to verify patterns work as expected before applying them broadly.
π Official Documentation: VSCode Settings Reference