We use subversion so we have subfolders named _svn in our solution. Doing a Find in Files returns strings from these subfolders. Is there any way to tell Visual Studio to ignore these files?
-
7This has bothered me quite a bit with Visual Studio's Find in Files. As @rafbel mentioned, I end up turning off the "include sub-folders" but that just ends up being extra steps or forgetting to turn it off later. It'd be nice to say search the main root folder, but ignore my "vendors" folder because i'm not worried about 3rd party libraries.. – Rich Finelli Feb 03 '16 at 16:11
-
1If someone finds or add this question to VS's UserVoice page, please post a link here so we can all upvote it! – pbristow May 24 '18 at 15:50
-
This drives me crazy. I recently discovered the ability to customize the "Look in" dropdown box. Our solution includes several projects that make up the installer portion, so it's nice to limit searches to just those projects while I'm working on it. So I created an Installer "Look in" profile. However, unless I want to manually specify every folder and subfolder of each project, I have to leave "Include sub-folders" checked. This picks up all the bin and obj folders. Very annoying. – Brian Colavito Jun 19 '19 at 16:53
-
I have .angular, .idea, debug, dist, node_modules and obj excluded from my project and visual studio 2022 keeps unfolding them and it's driving me mental. – Stijn Bollen May 02 '22 at 09:05
9 Answers
From "Find in Files", in "File Types" or "Look at these file types", you can use:
!*\ExcludeFolder\*
Example:
!*\bin\*;!*\obj\*;!*\.*;!*\ExcludeFolder\*

- 9,210
- 4
- 56
- 45
-
2That screen shot is from VS 2019. This answer does not work in VS 2017. – Scott Hutchinson May 04 '20 at 19:04
-
2This is exactly what I was looking for, when I ran into this problem in VS2019. Thank you! – Mass Dot Net Jun 05 '20 at 13:50
-
1Awesome stuff. I use Node and i never want to search the node_modules folder. Thanks – BoundForGlory Jun 13 '20 at 13:51
-
Please put clarification that `!*` and `*` are the enclosures. I assumed `!*\ ` was the enclosure. Example of full path would help - from the answer it is not clear if `ExcludeFolder` is the one, or `\ExcludeFolder` – Ajay Feb 21 '23 at 18:59
What you can do is to setup a set of folders that will be used for searching. In Find and Replace window, on the right hand side of "Look In" input you have a "Choose Search Folders" option where you can setup those sets of folders.
Just remember to turn off "Include sub folders" options if you have added root project folder.
If you don't have hundreds of folders this solution should work.

- 682
- 6
- 4
-
18No it should not, because it explains how to include folders into search instead of excluding them. That is quite a big difference IMHO. – Jan Palas Mar 14 '19 at 12:43
-
2I have hundreds of folders. They all live in one called `node_modules` lol – nothingisnecessary Jul 30 '20 at 17:45
-
Be aware that the "look in" list is shared between projects. So if you do this, then you open a different project, it will default to finding in the path you set in your previous project (until you change it). – cowlinator Nov 29 '21 at 23:20
Never had an issue with the global find until we moved to Visual Studio 2017 and started with Angular + .net Core applications... (mostly problems with the HUGE node_modules folder being searched)
I found that using the MSBuild exclusion property DefaultItemExcludes is working fine to exclude from global find in Visual studio 2017..
I now by default open up the project file (.csproj) for a new core project in VS2017 and adjust the property as follows to exclude the node_modules (sometimes I add the wwwroot too):
<DefaultItemExcludes>$(DefaultItemExcludes);node_modules\**</DefaultItemExcludes>
See also https://github.com/dotnet/cli/issues/7525 , there they advise to prepend the folders to exclude and seem to use a forward slash instead of backward slash, like this :
<PropertyGroup>
<DefaultItemExcludes>node_modules/**;$(DefaultItemExcludes)</DefaultItemExcludes>
</PropertyGroup>
Hope this helps anyone experiencing issues with VS2017 global find / search .

- 3,928
- 2
- 30
- 50
-
1Thanks very much. Weird that this question is asked many times on SO and no one figured this answer – Ashraf Sabry Mar 04 '19 at 20:46
-
-
All of my Angular projects in Visual Studio 2017 are "Folders" projects without any MSBuild files or project files (`*.csproj` etc), so I can't set `DefaultItemExcludes` anywhere. Am I SOL? – Dai Jun 14 '19 at 19:52
-
This does not to be working for VS 2019. I tried to exclude the `bootstrap.css` file but it was searched anyway. `
assets/css/**;$(DefaultItemExcludes) ` – VDWWD Apr 01 '20 at 12:22
I had this problem when moving to Windows 10 using Visual Studio 2015 and TortoiseSVN. Previously the .svn folders were all hidden so did not appear in search results. To solve this I simply went to the folder properties in Windows Explorer and checked the 'Hidden' attribute for the .svn folder. After refreshing the folder view in Visual Studio the .svn folder no longer appeared and is ignored when using Find!

- 159
- 1
- 6
-
-
1This doesn't seem to work in VS 2017. Further, it stops IISExpress from finding the folder, so it broke stuff too :( – pbristow May 24 '18 at 15:49
-
Working perfectly in VS 2015 Pro. I haven't seen any adverse effects yet :-) – BizzyBob Jun 14 '18 at 15:38
Instead of searching for files in a directory (your solution's directory, in this case), you could limit your search to the files that are part of the project or the solution. Those in the _svn directories will thus be ignored.

- 5,033
- 2
- 37
- 48
-
2We have nested projects folders inside the solution. So going into each one to find something is timeconsuming – Bernard Mar 23 '10 at 09:49
-
The 'Find in Files' dialog has a 'Look in' entry field that can be set to 'Current project' or 'Entire Solution'. Isn't the latter useful for you? I must have missed something, then... – Xavier Nodet Apr 06 '10 at 16:59
-
2@XavierNodet in my case at least, there are files I have in my solution that I never want to search, but I need in my solution so that they are copied to the output directory - ex. test fixtures or other static, text-based resources. – Tom Lianza Feb 14 '12 at 21:30
I found in Visual Studio 2017 especially when using Angular Cli that the generated javascript files or other build files can be added to your project sometimes unknowingly. This can cause several headaches including adding a bunch of files to the searches and really slowing things down, especially intellisense because it is searching all of the generated files on top of the source files.
The easiest way I have found to correct this is to simply right click on the build folder (i.e. {Project}/dist
) and select Exclude from Project
. This will remove the folder from the project but the generated contents will still be available for runtime, it is just hidden from the UI.
If you need to still see the files, you can show hidden directories and files by selecting Show all Files
or
click on the Icon:
on the top of the Solution Explorer.
Basically you want to exclude all build folders from your project/solution.

- 9,594
- 4
- 48
- 56
-
I don't think you can "Exclude" a folder, only files. At least on my version of Visual Studio 2017. When I right-click a folder in my project the Exclude From Project option does not appear on the context menu. – Pete Aug 30 '18 at 18:36
-
1
-
@richardtallent: I double checked both in VS2017 & VS2019 and the option to remove the folder is there. Please see my updated answer for a screenshot where to find the option. – Andy Braham Jun 15 '19 at 09:04
-
@AndyBraham, I'm using the WebSite project type (E24C65DC-7377-472B-9ABA-BC803B73C61A in the solution file), which I believe may be a legacy project type not available anymore in the New Project dialog. The "exclude" option is not available in the context menu for folders in projects of this type. I build my site outside of VS using Vue CLI/UI and Gulp, so the only fixed that worked for me was to just remove the project from my solution (I use VS Code for the front-end code anyway). – richardtallent Jun 18 '19 at 14:55
I don't think you can set this (after all, you are asking for "Entire Solution" search), but often you can remove the folder from the project / hide the directory in filesystem (for Web Site project type).

- 4,641
- 3
- 32
- 48
Adding the folder to .gitignore file worked for me in Visual Studio 2022 using Open/Folder... and also in Visual Studio Code (Open Folder...) with Angular project without any *.csproj file present.

- 2,351
- 3
- 11
- 15
If you are not using VS2019 or VS Code (for which the solution has already been found in other answers), as a workaround you can use the search in Far Manager, it supports masks to exclude certain files or folders from the search.

- 126
- 1
- 5