CORE JSC

International Technology Partnership

VS Code / Tools

Fixing VS Code's Global Search That Misses Matches Because of an Overly Broad search.exclude Pattern

A string that's definitely present in a file — confirmed by opening the file and finding it with Ctrl+F — comes back with zero results from VS Code's global search (Ctrl+Shift+F) across the same workspace. The file isn't being skipped at random; a search.exclude or files.exclude glob pattern, usually added to hide a build or dependency folder, is quietly matching more than whoever wrote it intended.

Core JSC Team·November 30, 2026
VS CodeSearchDeveloper ToolsConfigurationProductivity

The Problem

A specific string — a function name, a config key, a piece of text — is confirmed to exist in a particular file by opening that file directly and finding it with the editor's own in-file search (Ctrl+F). Running the same search across the entire workspace with VS Code's global search (Ctrl+Shift+F) returns zero results, as if the string doesn't exist anywhere in the project. The file in question isn't hidden from the file explorer, it opens normally, and nothing about it looks unusual — the global search is simply never looking inside it.

Why It Happens

search.exclude (and files.exclude, which search also respects by default) defines glob patterns for paths global search skips entirely

VS Code's global search respects both a dedicated search.exclude setting and, by default, whatever files.exclude already hides from the file explorer — both intended to keep noisy, irrelevant directories like node_modules, build output, or dependency caches out of search results and the file tree. A file matched by either of these patterns is excluded from global search entirely, with no indication in the search results panel that anything was skipped.

A glob pattern without careful anchoring can match far more than the single top-level directory it was meant to hide

A pattern like "**/dist": true, added with the intention of hiding one specific root-level build output folder, matches any directory named dist anywhere in the project tree — including an unrelated src/components/dist/ folder, a vendored dependency's own dist folder that happens to contain source worth searching, or any other coincidentally-named directory nested deep in the project. The pattern does exactly what its glob syntax says; it's just broader than whoever wrote it was picturing.

Exclude settings merge across User, Workspace, and Folder scopes, so the effective exclude set is often wider than any single settings file shows

VS Code settings combine across multiple scopes — a personal User settings file, a workspace-level settings file, and a per-folder settings file in a multi-root workspace — and exclude patterns from all of these merge together into the actual, effective set applied during search. A broad pattern added to a team's shared, repo-committed .vscode/settings.json combines silently with anything already in a developer's personal User settings, so inspecting only one settings file never shows the complete picture of what's actually excluded.

The Fix

1. Confirm the exclusion is real by temporarily disabling default excludes for one search

Search panel -> "..." (more options) menu -> toggle off
"Use Exclude Settings and Ignore Files"
-> re-run the same search

If the missing result appears once default excludes are temporarily disabled for that search, this directly confirms an exclude pattern — rather than something else entirely — is the cause, before spending time hunting through settings files for the specific culprit pattern.

2. Review the effective, merged exclude settings through the Settings UI rather than a single settings.json file

Settings (Ctrl+,) -> search for "exclude"
-> the Settings UI shows values from User, Workspace, and Folder
scopes together, with an indicator for which scope each value
came from — review all of them, not just the workspace's own file.

Because excludes merge across scopes, the Settings UI's consolidated view — rather than opening one settings.json directly — is the only way to see the complete, effective set of patterns actually being applied, including ones a developer's own personal User settings might be contributing without that being obvious from the project's committed configuration alone.

3. Anchor overly broad patterns to the specific top-level path they were meant to target

// Before — matches any "dist" folder anywhere in the tree:
"search.exclude": {
  "**/dist": true
}

// After — matches only the root-level dist folder:
"search.exclude": {
  "/dist": true
}

Replacing a bare **/name glob with a root-anchored pattern (or an explicit relative path) narrows the match to exactly the single directory that was actually intended to be hidden, leaving any other coincidentally-named folder elsewhere in the tree fully searchable.

4. Specifically review any shared, repo-committed .vscode/settings.json for exclude patterns the whole team inherited

cat .vscode/settings.json | grep -A5 '"search.exclude"|"files.exclude"'

A broad exclude pattern committed to a repo's shared settings file affects every team member who opens the project, often without anyone individually realizing it's there — explicitly checking this file for exclude patterns is worth doing even when the immediate suspicion points at personal settings, since the shared file is a common source precisely because it's easy to forget it exists.

Why This Works

Global search silently skipping a file that's genuinely present and searchable on its own is never a sign the search feature itself is broken — it's correctly honoring an exclude pattern that matches more broadly than whoever configured it realized, merged in from settings scopes that aren't all visible in one place. Confirming the exclude is the actual cause, reviewing the full merged settings rather than one file, anchoring overly broad patterns to their intended target, and specifically checking shared repo settings together turn an invisible search gap into a correctly scoped exclude rule.

Conclusion

A string that's confirmed present in a file but invisible to VS Code's global search is an overly broad search.exclude or files.exclude pattern, not a search feature failing to work. Temporarily disabling default excludes to confirm the cause, reviewing the full merged exclude settings across all scopes, anchoring broad glob patterns to their specific intended target, and checking a shared repo-committed settings file together turn a silently incomplete search into one that reliably covers the whole workspace.