Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Exclude FilesNew to Visual Studio Code? Get it now.
Exclude Files

Exclude Files

SaulBarros

| (1) | Free
Hide gitignored files in the Explorer, keep a whitelist for the ones you still need, and toggle it all from the status bar.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Exclude Files

Hides gitignored files in the VS Code Explorer, with a whitelist for the ones you still want to see (.env, *.tfvars, …), right-click actions to adjust both lists, and a status-bar toggle.

How it works

VS Code has no "hide this file" API. The only lever is the files.exclude setting, so this extension computes that setting and writes it to the workspace configuration.

  1. Read the .gitignore at each workspace folder root.
  2. Translate every pattern into a files.exclude glob.
  3. Drop any glob that would swallow a whitelisted pattern.
  4. Write the result to files.exclude.

files.exclude does not support negation, so the whitelist cannot be expressed as a rule. Step 3 is the whole trick: a whitelisted pattern stays visible because the exclude glob covering it is never emitted.

Only globs this extension added itself are ever removed. Entries you wrote by hand are detected and left alone, and only the workspace layer of files.exclude is read and rewritten — the merged view would drag VS Code's built-in defaults and your personal global settings into the repository's .vscode/settings.json.

Where the configuration lives

What Where
The computed exclusions files.exclude in .vscode/settings.json
Your whitelist and extra patterns excludeFiles.* in the same file
Multi-root workspaces each folder's own .vscode/settings.json

You rarely need to open it by hand — see the commands below.

Commands

Command What it does
Show a Hidden Pattern Again… Pick from the patterns currently hidden and move them to the whitelist. This is the way to un-hide something.
Toggle Hiding Same as clicking the status-bar item.
Open Settings Opens the Settings UI filtered to this extension.
Hide in Explorer Right-click a file or folder. Supports multi-select.
Always Show in Explorer Right-click, or use the editor tab context menu for a file that is already hidden.
Refresh Recompute now.
Disable and Clear Managed Excludes Removes everything this extension added and turns it off, so a reload does not bring it back.

The status bar shows 👁 12 while hiding and 👁 All when off. Click it to toggle.

Recomputation also happens on .gitignore changes, excludeFiles.* changes, workspace folder changes, and when workspace trust is granted.

Settings

Setting Default Purpose
excludeFiles.enabled true Master switch.
excludeFiles.useGitignore true Derive patterns from .gitignore.
excludeFiles.show ["**/.env", "**/*.tfvars"] Whitelist — always visible.
excludeFiles.hide [] Extra patterns to hide.
excludeFiles.statusBar true Show the status-bar toggle.
// .vscode/settings.json
{
  "excludeFiles.show": ["**/.env", "**/*.tfvars"]
}

Negated .gitignore entries (!.env.example) are added to the whitelist automatically.

Workspace trust

In an untrusted workspace the .gitignore is not read. A hostile repository could otherwise use its own .gitignore to hide files from you in the Explorer. Patterns you added yourself still apply.

Install

npx @vscode/vsce package --allow-missing-repository
code --install-extension exclude-files-0.2.0.vsix

Or press F5 for an Extension Development Host while working on it.

Develop

npm install
node tools/make-icon.js   # regenerate images/icon.png

Known limits

  • Only the .gitignore at each workspace folder root is read. Nested .gitignore files are ignored.
  • Whitelist matching compares glob patterns, not resolved file paths. Unrelated patterns that happen to overlap textually may keep an exclude from being emitted.
  • files.exclude also affects Quick Open and search results, not just the Explorer.
  • The computed setting lands in .vscode/settings.json, which is usually committed.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft