Aracılığıyla paylaş


Quick Replace, Find and Replace Window

Quick Replace allows you to search the code of one or more open files for a string or expression, and change all or part of any matches found. The selection moves from match to match, allowing you to consider each replacement in its surrounding context.

Note

The matches found are not listed in the Find Results windows.

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

To display Quick Replace

  1. On the Edit menu, expand Find and Replace.

  2. Choose Quick Replace.

    —or—

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

Quick Replace 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 string or expression that will be matched.

  • Find what
    Reuse one of the last 20 search strings by selecting it from this dropdown list, or type a new text string or expression to find.

    Option

    Description

    [string with wildcards]

    If you want to use wildcards such as asterisks (*) and question marks (?) in your search string, select the Use check box under Find Options and choose Wildcards.

    [regular expression]

    To cause the search engine to interpret your search string as a regular expression, select the Use check box under Find Options and choose Regular expressions.

  • Expression Builder
    This triangular button next to the Find what field becomes available when the Use check box is selected in Find Options. 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.

Replace With

These controls allow you to specify what will be inserted in the place of the matched string or expression.

  • Replace with
    To replace instances of the Find what string with another string, enter the replacement string in this field. To delete instances of the Find what string, leave this field blank. Select the drop-down list to display the last 20 items entered. To include regular expressions in the Replace with string, click the Use check box and select the Regular Expressions option.

  • Expression Builder
    This triangular button next to the Replace with field becomes available when the Use check box is selected in Find Options and Regular Expressions appears in the drop-down list. Click this button to display a list of regular expressions, depending upon the Use option selected. Choosing any item from this list adds it to the Replace with string.

  • Replace
    Choose this button to replace the current instance of the Find what string with the Replace with string, and find the next instance within the Look in scope.

  • Replace all
    Choose this button to replace all instances of the Find what string with the Replace with string, in all files within the Look in scope.

    Warning

    Set the Look in scope to include only those files that you want to modify.

Look in

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

  • Look in
    Select a predefined search scope from this list.

    Option

    Description

    Selection

    This option is available when text is selected in the code editor. 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. Searches within the current procedure, module, paragraph, or code block.

    Current Document

    This option is available when a document is open in an editor. 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. Searches all content displayed in this window for the Find what string. Replace and Replace All commands are not available.

    All Open Documents

    Searches all files currently open for editing as if they were one document. When the starting point of the search is reached 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

    Searches all files in the active project as if they were one document. When the starting point of the search is reached in one file, the search continues in the next 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 Match case selected will return "MyObject" but not "myobject" or "MYOBJECT."

  • Match whole word
    Only displays instances of the Find what string that are matched in complete words. For example, a search for "MyObject" will return "MyObject" but not "CMyObject" or "MyObjectC."

  • Search up
    When selected, files are searched from the insertion point to the top of the file.

  • Search hidden text
    When selected, the search will also include concealed and collapsed text, such as the metadata of a design-time control; a hidden 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:

    Option

    Description

    Wildcards

    Special characters such 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 changes the options displayed in the window to match.

Drop-down

View menu

Find (left drop-down)

Quick Find

Find in Files

Find Symbol

Replace (right drop-down)

Quick Replace

Replace in Files

See Also

Tasks

How to: Search Interactively

How to: Search Using Results Lists

How to: Search a Document Incrementally

Reference

Quick Find, Find and Replace Window

Replace in Files, Find and Replace Window

Other Resources

Find and Replace Window

Finding and Replacing