Software

Find and Replace Window

You can use the Find and Replace window to search for text strings, expressions, or entity names within the code of your documents. To access this window, from the Edit menu, click Find and Replace, and then select one of the options listed.

The Find and Replace window contains a toolbar with two drop-downs, one for find operations and one for replacing them. When you select an operation, the corresponding options for the operation are displayed. You can search and replace in one or more files or an entire solution for text, code, or symbols.

Figure 1. Find and Replace


Quick Find allows you to search the code of one or more open documents for a string or expression. The selection moves from match to match, allowing you to review each match in its surrounding context.

Note: The matches found are not listed in the Find Results window.

You can use any of the following methods to display Quick Find in the Find and Replace window.

To Display Quick Find

  1. 1.On the Edit menu, expand Find and Replace.
  2. 2.Choose Quick Find.

    -or-

    If the Find and Replace window is already open, on the toolbar, click the triangular View button on the left drop-down and then choose Quick Find.

Quick Find can search through a document either forward or backward from the insertion point. The search automatically continues past the end or start of the document into the unsearched portion. A message appears when the entire document has been searched.

Find What

These controls allow you to specify the matching string or expression.

Reuse one of the last 20 search strings by selecting it from this drop-down list, or type a new text string or expression to find.

Table 1. Quick Find

Option

Description

[string with wildcards]

Select the Use checkbox under Find options and then choose Wildcards if you want to use wildcards such as asterisks (*) and question marks (?) in your search string

[regular expression]

Select the Use checkbox under Find options, and then choose Regular expressions to instruct the search engine to expect regular expressions

Expression Builder

This triangular button next to the Find what field becomes available when the Use Checkbox is selected in Find options, and Regular Expressions appears in the drop-down list. Click this button to display a list of wildcards or regular expressions, depending upon the Use option selected. Choosing any item from this list adds it into the Find what string.

Find Next

Click this button to find the next instance of the Find what string within the search scope chosen in Look in.

Bookmark All

Click this button to display blue bookmarks at the left edge of the code editor to indicate each line where an instance of the Find what string occurs.

Look in

The option chosen from the Look in the drop-down list determines whether Quick Find searches only in currently active files.

Look in

Select a predefined search scope from this list.

Table 2. Look in Scopes

Option

Description

Selection

This option is available when text is selected in the code editor and searches only the selected text in the currently active document

<Current Block>

The name of this option indicates the location of the insertion point in the code editor and searches within the current procedure, module, paragraph, or code block

Current Document

This option is available when a document is open in an editor and searches only the active document for the Find what string

Current Window

This option is available when a searchable tool window, such as the View in Browser window, has focus. This option searches all content displayed in this window for the Find what string.

All Open Documents

This option searches all files currently open for editing as if they were one document. When reaching the starting point of the search in the current file, the search automatically moves to the next file and continues until the last open file has been searched for the Find what string.

Current Project

This option searches all files in the current project as they were one document. When reaching the starting point of the search in one file, the search continues in the next file until the last file in the project has been searched.

Find Options

You can expand or collapse the Find options section. The following options can be selected or cleared:

Match Case

Only displays instances of the Find what string that are matched both by content and by case. For example, a search for 'MyObject' with the Match case selected will return 'MyObject' but not 'myobject' or 'MYOBJECT'.

Match Whole Hidden Text

When selected, the search will also include concealed and collapsed text, such as the metadata of a design-time control. It is an undisclosed region of an outlined document or a collapsed class or method.

Use

Indicates how to interpret special characters entered in the Find what or Replace with text boxes. The options include:

Table 3. Search with Special Characters

Option

Description

Wildcards

Special characters as asterisks (*) and question marks (?) represent one or more characters. For a list, see Wildcards (Visual Studio).

Regular Expressions

Special notations define patterns of text to match. For a list, see Regular Expressions (Visual Studio).

Toolbar

A toolbar with two drop-downs appears at the top of the Find and Replace window. These drop-downs allow you to choose the type of search or replace you intend to perform and change the options displayed in the window to match.

Table 4. Find and Replace Toolbar

Drop-Down

View Menu

Find (left drop-down)

Quick Find

Find in Files

Find Symbol

Replace (right drop-down)

Quick Replace

Replace in Files

Figure 2. Find Results


Figure 3. Find Symbol Results