Mike Godin
Mike Godin

Reputation: 3937

How to actually search all files in Visual Studio

I am using Visual Studio. Say for instance I have a static public method named FooBar() in class Utils. Let's also say that I use this method in a lot of .aspx files. Let's say I change the method signature of FooBar() to FooBar(string), and subsequently I'd like to find all the instances of Utils.FooBar so I can update them.

Now let's say I go to the Solution Explorer search box, select "Search within file contents", and type Utils. Despite the fact that I make Utils.* method calls everywhere, the only thing that shows up is the Utils.cs file. If I keep typing Utils.FooBar, nothing shows up.

Right now, I am launching a Cygwin window and using grep since normal windows search is pretty useless too. But it seems like there there must be an actual way of searching within all files in Visual Studio. Am I missing something?

Upvotes: 153

Views: 275742

Answers (8)

Design.Garden
Design.Garden

Reputation: 4207

Preface: As others have said, ctrl+shift+F is the tool, but I am so often frustrated by the fact that the default options don't find everything!

Answer: If you want to search every file then, from the "Find in Files" tab:

  1. Click the ellipsis to the right of "Look in" then choose the folder containing your Solution.
  2. Set "File types" to *
  3. Click "Find All" and finally find what you were looking for.

Warning: The search could take a while and it may find occurrences in files that shouldn't be edited.

Search all files in the Solution.

Upvotes: 5

Dev Reborn
Dev Reborn

Reputation: 44

For Mac OS press Command + Shift + F.

Upvotes: 0

user2124444
user2124444

Reputation: 21

I've seen this happen when you move the project from one folder to another. I'm not sure how to fix this "the right way" but if you exit visual studio, delete the .vs folder that corresponds to your solution file, and then re-open the solution, it will recreate the .vs folder correctly for your new project location. You'll lose some customizations (like startup projects), but search will work again as you expect without you having to specify which folder to look in.

I have moved projects with some impunity in the past, so I'm not sure why it has been screwed up recently, but OneDrive is a relatively new part of my strategy, so it might be related.

Upvotes: 0

Vivek Nuna
Vivek Nuna

Reputation: 1

Visual Studio 2022 has come up with a very powerful search feature. I have used this feature in VS 2022 17.5.

In my case I just double-clicked the method name and pressed ctrl + t. and you see the magic.

enter image description here

https://devblogs.microsoft.com/visualstudio/new-better-search-in-visual-studio/

Upvotes: 3

Nash
Nash

Reputation: 321

One can access the "Find in Files" window via the drop-down menu selection and search all files in the Entire Solution: Edit > Find and Replace > Find in Files

enter image description here

Other, alternative is to open the "Find in Files" window via the "Standard Toolbars" button as highlighted in the below screen-short:

enter image description here

Upvotes: 17

Ahmed Ibrahim
Ahmed Ibrahim

Reputation: 751

Press Ctrl+,

Then you will see a docked window under name of "Go to all"

This a picture of the "Go to all" in my IDE

Picture

Upvotes: 42

n4feng
n4feng

Reputation: 2454

I think you are talking about ctrl + shift + F, by default it should be on "look in: entire solution" and there you go.

Upvotes: 232

Mike Godin
Mike Godin

Reputation: 3937

So the answer seems to be to NOT use the Solution Explorer search box.

Rather, open any file in the solution, then use the control-f search pop-up to search all files by:

  1. selecting "Find All" from the "--> Find Next / <-- Find Previous" selector
  2. selecting "Current Project" or "Entire Solution" from the selector that normally says just "Current Document".

Upvotes: 37

Related Questions