Chapter 3. Find What You Are Searching For

I didn’t spend too much time testing the Find features in the editor, as I was more focused on core editing and Microsoft IntelliSense functionality. However, there were times when I helped to analyze test-case failures, assisted in the full test pass, or just did what we call a bug bash, where the test team devotes an entire working day (if not the entire 24 hours) to try to find as many bugs as possible.

You can categorize searching within the editor into three buckets: keyboard searches, quick searches, and advanced searches. The keyboard searches tend to be the fastest, involving the least amount of interaction with the user interface (UI), but they can be limited in scope. The quick searches are your multipurpose searches. But, depending on what you are searching for and where you want to look for it, there may be a more efficient job search. And finally, the advanced searches—namely, Find In Files—are your Swiss army knife of search functionality, especially when you need to search anywhere for anything on the hard drive.

Searches from the Keyboard

The tips covered in this section are designed to limit the amount of UI you need to interact with to conduct a search. Avoiding UI interactions tends to save time, especially when you are repeating the action frequently throughout the day.

Incremental Search

Incremental search is a powerful search to use when you want to keep both your focus and your cursor in the editor when searching in the current document. It is powerful because it allows you to keep typing, meaning the search is driven by keystrokes. And you don’t need to interact with any UI.

Tip 3.1: How to behold the power of incremental search

To conduct an incremental search, follow these steps:

  1. Press Ctrl+I.

  2. Start typing the text you are searching for.

  3. Press Ctrl+I again to jump to the next occurrence of the search string.

    Note

Additionally, you can press Ctrl+Shift+I to search backward.

To stop searching, press Esc. You’ll see confirmation in the status bar that you are out of the incremental search mode.

Current Word Searches

These next tips illustrate what you can do and what you can customize when searching a currently-selected word.

Tip 3.2: You can use Ctrl+F3 to search for the currently-selected word without bringing up the Find And Replace window

Just select some text (or just have the cursor on the word you want to search for) and press Ctrl+F3. Ctrl+Shift+F3 will do a reverse search.

Tip 3.2: You can use Ctrl+F3 to search for the currently-selected word without bringing up the Find And Replace window

Note that a Ctrl+F3 search uses the following options:

  • Is case sensitive

  • Searches hidden text

  • Allows for partial matching

  • Does not use regular expressions

Tip 3.3: How to not automatically search for the currently-selected word

Go to the Tools–Options–Environment–Find And Replace page, and uncheck the Automatically Populate Find What With Text From The Editor option.

Tip 3.3: How to not automatically search for the currently-selected word

Now, when you hit Ctrl+F (Quick Find) or Ctrl+Shift+F (Find In Files) or Ctrl+H (Quick Replace), the Find What combo box will not automatically display the current word or selected text.

Repeat Last Search

Reducing the number of necessary keystrokes in a commonly repeated action saves time in the long run. Repeating the last search is definitely one of the ways you can take advantage of this philosophy. Instead of having to redo the last search, which may take several keystrokes and even involve using the UI, you can press a single keyboard shortcut to search what you last searched for.

Tip 3.4: You can use F3 to search for the last thing you searched for

Obviously, you can press the Find Next button in the Find And Replace window. But you can also press F3 to search for the next instance, and Shift+F3 searches for the previous instance of the search string.

Tip 3.4: You can use F3 to search for the last thing you searched for

Note that this keyboard shortcut is only for Quick Find and Find In Files, not for an incremental search.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.249.174