8

In Visual Studio Code (not to be confused with Visual Studio) there is a search interface (click the mag glass at top left).

It has a "files to include" field, and a "files to exclude" field.

I know that I can include or exclude a file from my search by entering the name of the file, or using a wildcard like *.js.

Is there a way to specifically include or exclude a directory by using these fields? If not, how would I do that?

Edit: Some have said that this question may be similar to How can I choose folders to be ignored during search?

I think it is fundamentally the same question, but as I said in a recent comment on that question: "There is nothing in the title of this question to indicate that you are asking a question about a specific tool (Visual Studio Code). And while you do have it tagged visual-studio-code - making it appear in searches about that tool - the searcher will not necessarily know that this question is about VS Code. Also, you use a Mac specific keyboard command that is not really relevant to the question at hand, and makes the question seem non-relevant to non-Mac users."

So, yes, I guess it's the same question. But I don't think it's reasonable to expect me to have found it.

zumafra
  • 1,255
  • 2
  • 13
  • 19
  • Take a look at this, its the same question: https://stackoverflow.com/a/33418660/8726546 – lekterable Aug 08 '18 at 00:09
  • Just putting the folder name in the "files to exclude/include" boxes works for me - you don't need to do anything special for folders. – Mark Aug 08 '18 at 00:23
  • I searched, but I didn't see that other question. Anyway, thank you both for the info. – zumafra Aug 08 '18 at 01:33
  • I just made a suggested edit to [How can I choose folders to be ignored during search?](https://stackoverflow.com/questions/29971600/how-can-i-choose-folders-to-be-ignored-during-search) to clarify that it involves Visual Studio Code. Hopefully, people will find it in the future. :-) – Super Jade Feb 07 '19 at 06:04
  • Possible duplicate of [How can I choose folders to be ignored during search?](https://stackoverflow.com/questions/29971600/how-can-i-choose-folders-to-be-ignored-during-search) – Super Jade Feb 07 '19 at 06:06
  • see answers here https://stackoverflow.com/questions/29971600/how-can-i-choose-folders-to-be-ignored-during-search – yehonatan yehezkel Mar 04 '19 at 12:11

3 Answers3

16

You could either change the global settings (CTRL + , by default), for example to ignore anything in node_modules

"search.exclude": {
  "**/node_modules": true
}

Or if you don't want to set a global setting, you can just add the foldername\* to the "files to exclude" field. So in our example

files to exclude node_modules\*

Hope this helps anyone searching for it in the future.


For reference: https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options

Dan Atkinson
  • 11,391
  • 14
  • 81
  • 114
Lavariet
  • 497
  • 8
  • 15
0

you can exclude or include a folder by using the files to include/exclude text boxes.

https://github.com/Microsoft/vscode/issues/17164#issuecomment-311750417

Ananda
  • 888
  • 9
  • 19
0

Update 1.73.1 finally addresses this issue and provides an easy way to include/exclude folders in the tree view

colby-ham
  • 457
  • 9
  • 13