Reputation: 123218
So in Visual Studio Code, I have a .vscode/settings.json
which defines some directories to not show.
I have some node_modules
that are specific to my project and maintained inside my repo. They all start with mycompany
. I'd like to show those in VSCode, but not others.
Here's what I have so far in .vscode/settings.json
:
{
// From http://stackoverflow.com/questions/33258543/how-can-i-exclude-a-directory-from-visual-studio-code-explore-tab
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/.vscode": true,
"**/.sass-cache": true,
"node_modules/mycompany**": false, // Hoping this will override next line
"node_modules/**": true
}
}
I've tried swapping the order of the last two lines but that doesn't work either. How can I ignore all files in a directory unless they start with a particular set of characters?
Upvotes: 1
Views: 2719
Reputation: 1747
I was trying to do the same thing, and also couldn't find a way to achieve this via files.exclude
setting, however I found a workaround utilizes another setting - "explorer.excludeGitIgnore": true
.
Enabled this setting, added .gitignore
that expresses what I need, which in your case would be:
# .gitignore
node_modules/**
!node_modules/mycompany**
Note: this works even though I am not using git in this repo, I basically have a .gitignore
that is not in any git repo.
Upvotes: 1
Reputation: 1528
Found a solution, not very elegant though )
{
"files.exclude": {
"**/node_modules/[^m]*": true,
"**/node_modules/?[^y]*": true,
"**/node_modules/??[^c]*": true,
"**/node_modules/???[^o]*": true,
"**/node_modules/????[^m]*": true,
"**/node_modules/?????[^p]*": true,
"**/node_modules/??????[^a]*": true,
"**/node_modules/???????[^n]*": true,
"**/node_modules/????????[^y]*": true
}
}
Upvotes: 5