Reputation: 180
I'm working with a project in Visual Studio Code that has a directory structure like this:
project-root
├── dirA
│ └── dirB
├── dirB
└── tests
├── dirA
└── dirB
I want to exclude dirA
and dirB
at the top level from the Explorer view using files.exclude
in my workspace settings, without excluding the nested dirA/dirB
, tests/dirA
, and tests/dirB
.
Using patterns like "**/dirA": true
and "**/dirB": true
in files.exclude
unfortunately also hides the nested directories since the glob patterns apply to all directories with those names at any depth.
Is there a way to specify exclusions strictly at the top level in VS Code, using files.exclude
or another method, so that only the top-level dirA
and dirB
are hidden, but not their namesakes deeper in the structure?
VS Code's glob pattern matching for files.exclude
does not provide a way to distinguish between directories at different levels of the project structure. The patterns apply globally, affecting all directories that match the pattern regardless of their depth relative to the workspace root.
Specific Glob Patterns: Using more specific paths (e.g., "/project-root/dirA": true
) does not achieve the desired effect since the patterns are relative to the workspace root, and specifying the root directly is not supported in files.exclude
syntax.
Unique Naming: Changing top-level directory names to be unique could work but is not always feasible due to naming constraints or project standards.
Manual Updates: Updating files.exclude
dynamically is impractical for larger or more dynamic project structures.
Upvotes: 0
Views: 160
Reputation: 50554
I don't think what you're looking for is possible (though I'd be happy to be wrong). You can get closer with ./dir{A,B}/[!d]*
. But it will fail to exclude folders and files under ${workspaceFolder}/dir{A,B}
that start with d
.
For docs, see https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options and https://code.visualstudio.com/docs/editor/glob-patterns.
Upvotes: -1