Get more done with search in Visual Studio
Over the years, the Search feature in Visual Studio has gotten faster and more capable. You might have missed some of the things it can do to help you be more productive and get the most out of Visual Studio. So, let’s take a closer look at how you can use Search in your daily work.
I hit Ctrl+Q to use Search every single day and have for years. It’s useful, it’s fast, and it helps me get my job done. Usage data shows that I’m an outlier and that most Visual Studio users don’t use Search as much as me. So, I thought it write up some of the ways I use Search to be more productive and share it with you here on the blog.
Windows and panels
You can search for windows or panels that you may have accidentally closed. For example, search for test to find and open the Test Explorer window:
I do this all the time with some of the custom tool windows provided by the various Visual Studio extensions I use.
In addition to searching the IDE itself, Visual Studio search also searches your solution items for filename, code, method, and other matches. In the following screenshot, a search for markdown has found the MarkdownMetaExtractor.cs file, the MarkdownMetaExtractor class, and two methods within the solution:
You can also do a “camel hump” search. In the following screenshot, a search for FSS has found a FolderSizeScanner file, class, and method:
I used to use Go To All… (Ctrl+,) to find files in my solution, but now I just use the Search instead. I find it easier to use just a single place for searching.
You can use the Visual Studio search box to find menu items and commands. For example, search for clean sol to quickly find and execute the Clean Solution command. The search results also offer a reminder of where to find this command in the menus as shown in the screenshot below:
This one is particularly useful for commands you don’t remember the keyboard shortcut for. So, instead of reaching for the mouse to find it, simply hit Ctrl+Q and start typing.
You can use the Visual Studio search box to find settings, options, and similar configuration items. For example, search for change theme to quickly find and open the dialog that allows you to change the Visual Studio color theme as shown in the following screenshot:
Visual Studio has a lot of settings. Like, a lot. And going through the Options dialog to find the setting can take a while if you don’t remember exactly where to go. Using Search for finding settings has completely changed how I interact with the Options dialog and has made it easier for me to toggle settings on/off more frequently as needed.
Most recently used
Before you start typing anything in the Search field, a list of your most recently used search results are shown. It’s a great reminder to start learning those keyboard shortcuts instead of searching for them commands all the time. That way, without searching at all, you can get to the three most recent results easily.
That’s my list of useful things I use search for in Visual Studio. I hope you find it useful too. Make sure to catch other tips and tricks videos and subscribe to the Visual Studio YouTube channel.
It would be nice to use Ctrl-Q instead of Ctrl-F to search code, but the Ctrl-Q code search appears limited to files, types, and members. Is there an option to search more generally in the code to match some of the capabilities of Ctrl-F?
I tend to use several of the more specific VS search features in concert, depending on where and what I am looking for.
In descending order of usage frequency:
Ctrl-T to search code solution wide. Usually to jump to types or files. I seldomly use the more specific filter options.
Ctrl-F to text search the current document and/or highlight occurrences in the editor (and editor scrollbar)
Ctrl-Shift-F to text search solution wide.
Ctrl-Q to search for VS menus/options/things that I can’t quite remember what their name is or where to locate them.
To be honest I do not quite see the usefulness of using Ctrl-Q to do a code search, as it is AFAIK less powerfuller/filterable than Ctrl-T. Also it requires me to use the mouse to switch to the “Code Only” mode, otherwise the results are “polluted” with things that are not code and do not interest me at that moment.
Likewise to do a VS stuff search, I tend to have to manually switch to “VS Only” mode, because otherwise I get code results mixed in.
This makes Ctrl-Q into a feature which is neither quite here nor there. At least in my opinion.
The different search options make it confusing.
I like to see a ‘unified’ search. One shortcut, one search window, on result set.
This probably won’t solve all your issues with Ctrl + Q, but when you have that search field selected you can actually use Ctrl + Tab to switch between the three modes (All, Code, Visual Studio). No need to reach for the mouse 🙂
That’s exactly what I think, and that’ll work better for me in my project jabejabar
The old Go To All (Ctrl + T or Ctrl + . iirc) used to be able to go to methods, types, and files separately using search prefix. This feature seems to be gone from this search. Also, I cannot trust it at all as it seems to break often and shows no results or unrelated results. Good idea, poor execution.
Ctrl-Q doesn’t seem to work for me (does nothing at all) if a source code tab is currently selected.
I have to select Solution Explorer before it will actually do anything.