Folders or files can be excludes from search in Visual Studio Code. It helps with performance. To add folder and files for excluding in search
- Go to File -> Preferences -> Settings (or on Mac Code -> Preferences -> Settings)
- Pick the Workspace tab
- Filter settings by searching for ‘Search’
- Add the files and folder in ‘Search: Exclude’
If you choose File -> Preferences -> Settings -> User, then you configure the exclude folders globally for the current user. Refer to below image for more details
Include **
at the beginning of any search exclusion to cover the search term over any folders and sub-folders. If you enter example
, that will match every folder and file named example
in the workspace. If you enter ./example
, that will match the folder example/
at the top level of your workspace. Use ! to exclude those patterns from the search. !example
will skip searching any folder or file named example.
Excluded folders can also be added in files.exclude
and files.watcherExclude
as they might be useful too. This snippet contains their explanations and defaults:
// setting.json code snippet { // Configure glob patterns for excluding files and folders. For example, the files explorer decides which files and folders to show or hide based on this setting "files.exclude": { "**/.git": true, "**/.svn": true, "**/.hg": true, "**/CVS": true, "**/.DS_Store": true }, // Configure glob patterns for excluding files and folders in searches. Inherits all glob patterns from the `files.exclude` setting. "search.exclude": { "**/node_modules": true, "**/bower_components": true }, // Configure glob patterns of file paths to exclude from file watching. Changing this setting requires a restart. "files.watcherExclude": { "**/.git/objects/**": true, "**/.git/subtree-cache/**": true, "**/node_modules/*/**": true } }
Reference