Visual Studio: Incremental Search

Making Search Easier to Use.

Visual Studio’s “Quick Find/Replace” (F/R) is a common staple for many web developers seeking to make batch replacements of strings within their code.
However, one often overlooked feature within the IDE is “Incremental Search” (IR).
This handy utility provides find capabilities similar to that of many “web developer” toolbars provided by leading browsers.

While F/R does batch replacements in short-order, it lacks quick-feedback necessary for searching before the target string is found.
For example, let’s say you need to find a variable name, but like many blocks of code, names are reused in part across different variables (firstName, lastName – both share the string “Name”). Another commonly used word in code is “report.”
Incremental Search allows you to search for a string, one letter at a time and also allows you to adjust your search parameters on the fly.

Here’s an example of C# code where I need to isolate many instances of strings containing the word “report.”

1-vs-incrementalsearch

To begin my search, I select the key combination of [Ctrl] + ‘I’.
Now, you will see binoculars with a green down arrow.

2-vs-incrementalsearch

Next, to begin searching for a word I simply begin typing that word (no separate dialog is necessary – saves time) and strings within the current document matching the letters you’ve typed will be highlighted.
In this case, I typed “report” so all words beginning with that word appear in green.

3-vs-incrementalsearch

To iterate to the next matching string, I simply reenter the same key combination that began the IR – [Ctrl] + ‘I’.
Or, to reverse my search order I may use [Ctrl] + [SHIFT] + ‘I’.

4-vs-incrementalsearch

In the event you’ve typed something for which there’s no match, the search will stop and you will receive a message at the bottom-left of the screen indicating so.

5-vs-incrementalsearch

As described above, there are many handy keyboard shortcuts that may make using IR more efficient.

6-vs-incrementalsearch

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s