Quick Search, Replace and Navigate in Visual Studio IDE (A Must Read Post)
I would call this post as Tips/Tricks post because this post contains information about Visual Studio IDE features. I can see large number of developers are not familiar with these features. So, I thought writing a blog post collecting searching, replacing and navigating tips which is vital to happy and productive.
Navigate To (Ctrl+,)
Navigate To (Ctrl+,)
This feature provides search-as-you-type support for files, types, and members to match the input string. You can find this feature under the ‘Edit’ menu or use the keyboard shortcut ‘Ctrl + ,’ (Ctrl+Comma) to bring up the ‘Navigate To’ dialog box. Following is a screen of the ‘Navigate To’ dialog.
You just need to double click on any search result to navigate to that page.
Quick Launch (Ctrl+Q)
Quick Launch is used to quickly search and execute actions for IDE assets such as options, templates, menus. You can't use Quick Launch to search for code and symbols, Navigate To dialog box works fine for this (as given above). The Quick Launch search box is located at the top-right corner of the menu bar and is accessible by pressing Ctrl+Q. Simply enter your search string in the box.
For example, I would like to search for database designer settings, I will type ‘database designer’ in Quick Launch box.
Now, just click on the search result to bring database designer setting dialog up.
Incremental Search (Ctrl+i)
Incremental Search is a great tool that allow searching within current document, and enables you to do so without having to bring up a dialog. Just press Ctrl+i on any page and start typing, it will start highlighting the matching. After typing the key, start pressing Ctrl+i to navigate forward through highlighted items and start pressing Ctrl+Shift+i to navigate backward through highlighted items.
Find and Replace (Ctrl+Shift+F and Ctrl+F)
Find and Replace is one most developers knows about. Ctrl+Shift+F brings a dialog allow you searching and replacing things whereas Ctrl+F only allow you searching.
When I pressed Ctrl+Shift+F I got following screen. Here, you will have option to select the range for searching (Look in), you can replace things, you can bookmark things etc.
When I pressed Ctrl+F I got following screen. Here, you will have option to select the range for searching.
Find Usages (Shift + F12)
In Visual Studio IDE, when we press F12 to ‘go to definition’ and it is very useful to see where it is defined. But what if I want to see how many time thing is used and what are the files? This can be done using ‘Find Usages’ technique. To take advantage of it, simply select or move the cursor onto a method/type and press ‘Shift+F12’.
For example, to see about a method GetDistrict() like how many time this is used and what are the files I just moved cursor on the method and pressed Shift+F12 and boom, you can see the search result at the bottom.
Navigate Backward/Forward (Ctrl + Minus and Shift + Ctrl + Minus)
This is another useful thing you should know. Have you ever navigated to a different code file, looked at something, and then wanted to navigate back to where you came from? For example, you use F12 to ‘go to definition’ and then want to return back to the code that used it or back and forth? For this you need backward/forward navigation.
So, press Ctrl+Minus to navigate backward and press Shift+Ctrl+Minus to navigate forward.
Hope this helps.