πŸ”§ VSCode settings.json Cheat Sheet

πŸ”§ 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.json in 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!
  }
}

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.exclude by 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 false overrides in files.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? #

  1. Check JSON syntax - Use VSCode’s JSON validation
  2. Reload window - Ctrl+Shift+P β†’ “Developer: Reload Window”
  3. Check setting precedence - Workspace overrides user settings
  4. Verify glob patterns - Test with simple patterns first

Files Still Showing? #

  1. Clear editor history - May cache old file lists
  2. Check multiple exclusion settings - files.exclude, search.exclude, etc.
  3. Restart VSCode - Sometimes required for complex changes
  4. 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
}

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