1

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?

mikemaccana
  • 110,530
  • 99
  • 389
  • 494
  • 2
    I am looking for the same thing, but according to VSCode github issue, it is not support yet. https://github.com/Microsoft/vscode/issues/869 – John Siu Jun 27 '16 at 18:03

1 Answers1

5

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
    }
}
Viktar K
  • 1,409
  • 2
  • 16
  • 22
  • This will ignore everything except stuff that **starts** with `mycompany`. In order to also exclude e.g. `mycompanyxyz`, you'd have to add `"**/node_modules/mycompany?*": true` –  Dec 06 '16 at 10:56