How to actually search all files in Visual Studio - 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?

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

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:
selecting "Find All" from the "--> Find Next / <-- Find Previous" selector
selecting "Current Project" or "Entire Solution" from the selector that normally says just "Current Document".

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

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
Other, alternative is to open the "Find in Files" window via the "Standard Toolbars" button as highlighted in the below screen-short:

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:
Click the ellipses to the right of "Look in" then choose the folder containing your Solution.
Set "File types" to *
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.

Related

Visual Studio 2019 Search History not in 'table'

Alright so I recently did a clean install of visual studio and one thing changed from last time.
With vs2019, I think, came the different looking "Search History". Here are two screens of what exactly I mean with that. New looking history and here is the old one
I'm just not sure why now I only get the old one. I found out that the new one only appears with CTRL + SHIFT + F and the older one with regular CTRL + F. Is there are way so that the default CTRL + F window displays the same output window? (the newest one)
At first I didn't really like it that much, but now I prefer it. I'm running VS2019 Version 16.5.2.
Edit: And also, this is where I used to get the table version if anyone was wondering. Now it's just this old text thing.
In the "Find in Files" tool window, ensure "Find results table" is selected, not "Find results 1 window":
You can customize the keyboard shortcut.
Go to Tools\Options
Navigate to Environment\Keyboard
Under "Show commands containing", type Edit.FindinFiles
Under "Press shortcut keys", press the desired keyboard shortcut (i.e. in your case Ctrl+F)
Click Assign and then OK
See screenshot here
Tools > Options > Environment > Preview Features > Check "Use
Previous Find in Files"
Ctrl+Shift+F > Open Result options > Select
"Find results table"
Close the Find and Replace tool window and
revert the aforementioned "Use Previous Find in Files" setting
(optional)
Perform a search (either Find in Files or simply through
the standard Ctrl+F find prompt) Your results will then appear in
the advanced tabular "Find results table" window.
Presumably this setting is also found elsewhere but I haven't been able to find it without turning off the Find in Files preview feature.
https://stackoverflow.com/a/63789479

How to search VS2012 - only in certain file type

this should be a nice, easy fix for someone.
I want to search for let's say "url" but I only want to search *.cs files because I don't want the search tool to return all the HTML instances of "url"
I'm sure I was able to do this in previous versions of Visual Studio
Yes, it was indeed a nice easy fix...
Whereas:
Ctrl-F (find) the scope was automatically set to "document".
When you pressed Ctrl-Shift-F, the scope was set to entire solution.
Now - Ctrl-Shift-F brings up "Find in Files" which is what I wanted.

How do you find all references to a method or property in Xcode?

If you have a method, e.g., loadMediaImages in a .h file, how do you find all references to that method in the project? In Visual Studio there is a "Find All References" option on the content menu when you highlight and click the method name. Anything similar in Xcode?
Using the "Search Navigator" it's possible to search for symbol references within a project or workspace. Click on the little magnifying glass icon in the search box to "Show Find Options", and then select the Style: Symbol References.
Note: This is in Xcode 4.6, but may have been present in earlier versions.
I was looking for similar option. I do not know why Xcode did not included that.
But there is a work around I use until Apple give that option in Xcode.
Try this in the source code (.m) file,
Select the symbol, right click -> Refactor -> Rename
-> Give a name whatever you wish, then press Preview.
Now you can see all the references. You can Cancel/do not rename it. :)
Or press Cmd + Shift + F, and choose optons Find > References > Matching or Containing. But it will search all text with similar name. Not elegant like Refactoring.
You could do a search in the whole project... I don't have a screen ready but I know Xcode can.
Haven't seen this in Xcode. Just FYI you are able to do that with AppCode though.
If I'm not mistaken, Xcode 4 (not sure about previous versions) does not support a Find All References search. You can perform a text search within the entire project by pressing Shift+Cmd+F (Find in Workspace in the Edit menu), but this does not find exact "references", just matching text. You're best bet is using the Refactoring menu, as talked about in Finding all references of a variable or a method in Xcode4, but it is not very clean and requires more work than it should.
Find selected symbol in workspace is what you need
right click on the method/property -> Find -> Find selected symbol in workspace
focus the property/method and press ⇧ + ⌃ + ⌘ + F (or you can have a custom one)
Does basically the same search as Refactor -> Rename does

Limit search to specified Folders or File Types in Visual Studio?

Is there a way to limit a search (via the "Find and Replace" dialog) in Visual Studio to specified folders or file types?
Yes, in the find/replace window you can:
specify the file types in the "Look at these file types" option
and choose the folders in the ... button of the "Look in" option.
I can't believe this issue still exists in VS2015. We have a solution explorer folder tree. Why is "Current Selected Folder" not an option in the drop down. The "..." doesn't default to starting in the solution folder, I have to browse across the network to t the share, then drill down through all the folders to get at a folder that is ALREADY right there and selected in the solution explorer. Dreamweaver has had this functionality for its search for at least a decade (maybe longer).
Click Find in Files
Choose search folders three dots button "..."
Choose desired folder
Verify folder name and click desired action
Fastest folder search in VS:
As said in other answers, there is no immediate way to limit your search to a given folder within the current solution. (There are at least 3 feature requests for this in visualstudio.uservoice.com that have all been closed for lack of upvotes.)
But here is the fastest workaround that I could find.
Works without leaving VS and with keystrokes only (no mouse action required):
In Solution Explorer select the folder to search within.
Press Ctrl-C (copies folder path to clipboard).
Press Ctrl-Shift-F to open "Find in Files".
Enter your search term, then press Tab to forward the cursor to the "Look in" field.
Press Ctrl-V to paste in the folder path from clipboard.
2020-Update: Actually you can select the folder (also the current directory with two clicks) and define file types in Microsoft Visual Studio Professional 2019, Version 16.7.5
While the Choose Search Folders works, it could be much better. I would really like to choose folders to exclude as well as include because sometimes folders are nested. You may want a folder but only some of the subfolders.
But by far the worst inconvenience is that it is not stored with the solution. If I go to the trouble of defining a search, and close VS, then reopen, I have to define it all over.

Forcing the Solution Explorer to select the file in the editor in visual studio 2005

In Visual Studio 2005, whenever I would view a file in the main editor, the Solution Explorer would find and highlight that file. Some time ago, this stopped working and the Solution Explorer would do nothing.
This has become quite a pain since following a chain of "Go To Definition"s can lead you all over your solution. Where is the setting to turn this back on?
Click on the Tools → Options menu. Select the Projects and Solutions → General option page.
Make sure "Track active item in Solution Explorer" is checked. That should do it.
I like to keep this option turned off (especially when working with a big project), but it's useful to be able to find the file in the tree now and then. I found a way to do this here.
I hope I'm not being too verbose here, but here's the guide to making this work that I wrote for my work's wiki:
Go to Tools->Macros->Macro Explorer.
In the Macro Explorer tree that comes up, right-click MyMacros, and then New Module....
Call the new module SyncItem (if you want).
Right-click the new module, then Edit.
Paste this into the code window. (I don't know or care if the Imports lines are necessary; they're just there by default.)
code:
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module SyncItem
Sub SyncSolutionExplorer()
DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
End Sub
End Module
The macro is most useful if you bind it to a keystroke. Here's how to do that:
Go to Tools->Options, then select Environment->Keyboard.
Find the new macro in the list (start typing "syncitem" or similar in the search box).
I choose Alt-Shift-T (which this dialog box likes to call Shift-Alt-T) for, um, "Tree," I guess? If you're a fan of Edit.LineTranspose, whatever that is (I think it swaps the current line with the following one), then you might like to pick a different shortcut.
I just discovered that ReSharper can do what Owen suggests. I have disabled the "Track active item in Solution Explorer"-setting, and when I'm working in a source-file I press Shift + Alt + L and the file is selected in the Solution Explorer. I haven't changed the binding, so I guess that is the default. The upside to this is that you don't have to create a macro and then bind it to a keystroke (although not very difficult, it still has to be done). The downside is that ReSharper isn't free, so it's probably not a solution for everybody.
Navigate to Tools -> Options
Select "Projects and Solutions" in the tree view on the left
Select "Track Active Item in Solution Explorer"
Tools->Options->Project and Solutions->General
Check the box "Track Active Item in Solution Explorer"
Tools -> Options -> Environment -> Keyboard
Assign the command
View.TrackActivityinSolutionExplorer
(I use Alt+L)
then to use always hit Alt+L followed by Alt+L
which turns on the feature and locates the file in the source tree and then turns it off again to stop the location bouncing around when you do not want it to.

Resources