Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code search.exclude doesn't work

Tags:

I can't make search.exclude settings to work, so that it excludes build folder.

Here's screenshot: enter image description here

like image 305
Sebastian Avatar asked Aug 26 '17 11:08

Sebastian


People also ask

How exclude files from VS code search?

Persistent Exclusions From menu choose File ➡️ Preferences ➡️ Settings ➡️ User/Workspace Settings and filter default settings to search . You can modify the search. exclude setting (copy from default setting to your user or workspace settings). That will apply only to searches.

How do I enable search in Vscode?

VS Code allows you to quickly search over all files in the currently opened folder. Press Ctrl+Shift+F and enter your search term. Search results are grouped into files containing the search term, with an indication of the hits in each file and its location.

Where is the Vscode settings JSON?

Depending on your platform, the user settings file is located here: Windows %APPDATA%\Code\User\settings.json. macOS $HOME/Library/Application\ Support/Code/User/settings.json. Linux $HOME/.config/Code/User/settings.json.


1 Answers

Just in case this helps anyone else, here's a list of things that could be affecting whether your file/search exclusion settings are working as expected.

  • Double-check whether you're using the right patterns; you can see what kinds of patterns VS Code supports here. One common problem is to not add * before an extension you want to exclude, e.g. **/.min.js will exclude all files named ".min.js", while **/*.min.js will exclude all files ending in ".min.js".
  • Make sure the "Use Exclude Settings and Ignore Files" gear is toggled on (it's next to the "files to exclude" field; if you don't see it, click the little "..." under the "Replace" field). Turning it on will exclude any patterns in your search.exclude settings and patterns defined in any .gitignore files. This only affects whether your exclusion settings will be applied to your search; any pattern you put into the "files to exclude" input field will always be applied. screenshot showing the search tab open, the location of gear icon to "Use Exclude Settings and Ignore Files"
  • If you don't want to exclude .gitignore patterns, set search.useIgnoreFiles to false (it's true by default). If a pattern is excluded in some .gitignore file and search.useIgnoreFiles is true, even if you add that pattern to your search.exclude and set it to false, it will still be ignored (see this issue).
  • Any patterns in files.exclude will automatically be excluded from search results, not just from the file explorer.
  • All of the default patterns will be excluded even when you create your own files.exclude or search.exclude settings field. To override the default exclusion patterns, you must copy each default pattern into your user-defined settings and set them to false, e.g. "search.exclude": {"**/node_modules": false, "**/bower_components": false}.
  • As noted by the accepted answer, any currently opened files will always be included in results, even if they're excluded in your settings.
  • As of now, VS Code doesn't support negated glob exclusions, so if your search.exclude has patterns like this {"**/*": true, "**/myfolder": false}, files in "myfolder" won't be included in your results. Instead, you must exhaustively list all folders you want excluded.
  • Any settings in User Settings will be applied globally while Workspace Settings will only apply to the current workspace, so make sure you're placing your settings in the section you want.

If you're still having problems, you can see which folders VS Code is excluding by setting the log level to trace and reading the output when you perform a search (see here for more instructions).

like image 72
Galen Long Avatar answered Sep 24 '22 02:09

Galen Long