#75 Use wildcards and regular expressions while searching

Did you know that you can search in Visual Studio using wildcards and regular expressions (in addition to the regular text search) right from the Find and Replace window? This short tip/trick video shows you how.

Expand the Find options, and check Use:  This will enable you to select either wildcards or regular expressions. With out this selected, the expression builder is disabled. Now, that little grayed-out arrow, called an expression builder, next to the Find what: text box is enabled. Depending on if you chose the Wildcards or RegEx option, the expression builder is a nice little reminder of the search symbols that can be used.

http://scottcate.looplogic.com/vstricks075

#74 How to not automatically search for the currently selected word

When you press [CTRL]+[F] for find, one of the nice features of Visual Studio is the context find that happens. The word/phrase that your cursor is currently on is forwarded to the “Find What” section of the dialog box. The thinking here is pretty simple, which is, you’re probably going to search for another instance of the word/phrase you’re currently on. Well if you use [CTRL]+[F3] like in VSTricks #070, you wouldn’t be doing that 🙂 VSTricks #074 is about not auto populating the current text in the “Find What” field. This video shows you how to turn it off, which is much nicer if you’re mainly wanting to do a custom search, or search again.

Go to the Tools – Options – Environment – Find and Replace, and uncheck the “Automatically populate Find What with text from the editor”.  Now, when you hit [CTRL]+[F] (Quick Find) or [CTRL]+[CHIFT]+[F] (Find in Files) or [CTRL]+[H] (Quick Replace), and so forth… the Find what combo field will not be auto populated with the current word or phrase.

#73 Hide the Quick Find / Quick Replace window after the first search hit

Let’s say you are searching for some text and you already know about F3 and Shift+F3, so you want the [CTRL]+[F] Quick Find or the [CTRL]+[H] Quick Replace window to disappear after the first search. Go to Tools | Options | Environment | Find and Replace page, and check the Hide Find and Replace window after a match is located for Quick Find or Quick Replace.

#72 Use Ctrl+H to bring up the Quick Replace Window

You’re probably used to using [CTRL]+[F] to open the Find/Replace dialog. Did you know that [CTRL]+[H] will open directly to the Quick Replace dialog? The command is Edit.Replace, in case your keybindings are different.  You’ll need to press the Replace or Replace All button to invoke the find and replace.  Additionally, you can customize your find and replace experience by expanding the Find options chevron control. I’ll also do a quick showing of [CTRL]+[SHIFT]+[H] to show the difference between Find/Replace in current document vs. Entire Solution.

 

#71 Bookmark all of your Quick Find results

Sometimes when you’re looking for something in code, it would be nice for the results to persist. Instead of routing the results to the standard find box, this tip / trick shows you how to add a bookmark to all of the result findings. Then you’re free to use the keyboard shortcuts around bookmarking to navigate the results.

 

And if you’ve accidentally bookmarked half of your code by searching for a frequently-used search term (like i did the first time i tried this), simply open the Bookmark Tool Window (View – Bookmark Window), do a [CTRL]+[A] to select all bookmarks, and then hit delete.

The keyboard shortcuts around bookmarking are generally bound to …

[CTRL]+[B],[N] = Next Bookmark

[CTRL]+[B],[P] = Previous Bookmark

[CTRL]+[B],[C] = Clear all Bookmarks

SPECIAL NOTICE

If you’re in the habit of using [CTRL]+[SHIFT]+[F] over [CTRL]+[F] to use Find in Solution over the default find options, you will not see the bookmark results button. It’s only on the default find dialog.