Use files.exclude:
- Go to File -> Preferences -> Settings (or on Mac Code -> Preferences -> Settings)
- Pick the
workspace settings
tab - Add this code to the
settings.json
file displayed on the right side:
// Place your settings in this file to overwrite default and user settings.
{
"settings": {
"files.exclude": {
"**/.git": true, // this is a default value
"**/.DS_Store": true, // this is a default value
"**/node_modules": true, // this excludes all folders
// named "node_modules" from
// the explore tree
// alternative version
"node_modules": true // this excludes the folder
// only from the root of
// your workspace
}
}
}
If you chose File -> Preferences -> User Settings then you configure the exclude folders globally for your current user.