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

- 1,225
- 1
- 16
- 27
-
1Hm, interesting - I can reproduce that, but.. now always. Seems like it might be related to VSCode being opened before the `build` directory is created? Anyway, [#24677](https://github.com/Microsoft/vscode/issues/24677) seems relevant. – Gama11 Aug 26 '17 at 12:33
5 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. - 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 andsearch.useIgnoreFiles
is true, even if you add that pattern to yoursearch.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
orsearch.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).

- 18,334
- 18
- 100
- 135

- 3,693
- 1
- 25
- 37
-
35Wow it was the "Use Exclude Settings and Ignore Files" gear icon for me. Not intuitive. – John Harding Aug 29 '19 at 16:53
-
Is it possible to apply `"Use Exclude Settings and Ignore Files" ` option to `files.exclude` too? Seems its only available for `search.exclude` :( – Muhammad Qasim Sep 27 '19 at 06:40
-
1What a wildly bad design (the hidden gear toggle) that apparently hasn't been fixed in 3 years. Thanks for the nice summary. – fastmultiplication Jan 08 '22 at 04:42
This looks like this bug: https://github.com/Microsoft/vscode/issues/31819 - search.exclude
won't apply to open files.

- 15,081
- 5
- 76
- 91
**/build
did not work for me. Instead I use build/**
and it works.

- 950
- 8
- 18
-
Is this a comment on one of the other answers? What are you referrng to? – Yunnosch Nov 13 '20 at 11:43
-
This is an answer on how to fix the problem. OP wants to ignore `build` folder and I can see they used `**/build` but they need to use `build/**`. I will rename my answer `dist` -> `build` so it's more clear. – tudorprodan Nov 13 '20 at 15:34
It seems that search.useRipgrep ignores the exclude settings. For me the exclude started working when I disabled search.useRipgrep.
My Environment: Windows 10; VSC installed in User Directory (as recommended per last Update).

- 1,587
- 16
- 22
I haven't managed to get VSCode to ignore a folder with search.exclude
, regardless of the position of **
and so on.
However, what worked for me is creating an .ignore
file and then enabling "search.useParentIgnoreFiles": true
in the workspace settings.
My folder layout:
root/
...
text/
.ignore
code_ner
...
output/ <- want to ignore
envs/ <- want to ignore
Contents of the .ignore
file:
envs/
code_ner/output

- 2,577
- 18
- 38