ReSharper Web Help

ReSharper | Find | Search with Pattern

This dialog box helps create a custom code pattern, search for it and replace it. Depending on your goals, you can switch two modes in the Search with Pattern dialog box:

For more information, see Structural Search and Replace.

Find mode

By default, the Search with Pattern dialog box opens in the Find mode. The controls that are available in this mode are described in the table below.

Item Description
Menu bar This area contains menu items.
Language selector Allows choosing a programming language of the pattern.
Find Click this button to switch to the Find mode.
Replace Click this button to switch to the Replace mode.
Pattern Catalog Click to open the Custom Patterns page of the ReSharper options and look through the list of existing patterns.
Recent Searches Click to expand the list with recently used custom patterns.
Search area This area contains controls that allow you to create a custom pattern and specify search options.
Search pattern In this area enter your own search pattern using placeholders and plain text.
Look in Use the drop-down list to specify the search scope. Several scopes are provided:
  • Entire Solution
  • Current Project
  • Current File
Match similar constructs Use this control to specify whether to match similar constructs.
ReSharper considers following constructs as similar:
  1. Single-line statement and single-line statement that is enclosed in braces.
  2. Binary expressions as they are specified in the pattern and in reverse order.
  3. Expressions as they are specified in the pattern and expressions with different order of operands.
  4. Expressions where operands are enclosed in parentheses and expressions where operands are not enclosed.
  5. Postfix and prefix increment operators.
  6. Methods with different access modifiers.
Placeholder area This area contains controls that help you create placeholders and manage them.
Add Placeholder Click this button to create new placeholder. There are 5 types of placeholders:
  • Argument
  • Expression
  • Identifier
  • Statement
  • Type

After you choose the desired type, the Create/Edit Placeholder dialog box opens.

The following controls can be used in this dialog box:

  • Name - specify the placeholder name (for all placeholders).
  • Limit minimal number of arguments/statements - define minimum number of placeholder occurrences (for argument and statement placeholders)
  • Maximal - define maximum number of placeholder occurrences (for argument and statement placeholders)
  • Expression type/Type - select an item from the drop-down list to specify the type of placeholder (for expression and type placeholders)
  • Or derived type - select this check box to match expressions or types which have chosen type or its derived types (for expression and type placeholders)
  • Identifier name regexp - define regular expression for identifier name (for identifier placeholder)
  • Case sensitive - specify whether the identifier is case sensitive (for identifier placeholder)

Edit

Click this button or double-click at the placeholder name to edit the selected placeholder using the Create/Edit Placeholder dialog box.

Remove

Click this button to remove the selected placeholder.

Command buttons

Command buttons that are available in this dialog box and are used to initiate immediate actions.

Find

Click this button to perform your search.

Save

Click this button to save current pattern to the catalog. To access the pattern catalog, open the Custom Patterns page of the ReSharper options.

Close

Click this button to close the Search with Pattern dialog box.

Replace mode

Most controls in the Replace mode are completely the same as in the Find mode. The table below describes additional controls that appear in the Replace mode:

Item Description

Replace area

This area contains controls that allow to create a replace pattern and specify actions after the replacement.

Replace pattern

In this area enter a replace pattern using placeholders and plain text.

Format after replace

Specify whether to apply formatting to code.

Shorten references

Specify whether to replace fully qualified names with short names.

Command buttons

Command buttons that are available in this dialog box and are used to initiate immediate actions.

Replace

Click this button to find pattern occurrences and specify which of them to replace.

See Also

Procedures

Reference

External Links