PhpStorm 2021.2 Help

Structural search and replace dialogs

Use these dialogs to find and replace fragments of code that structurally match the suggested search template.

Item

Description

Available in

Search template

Use this text area to specify the template based on which PhpStorm performs the search process. You can type the template code in the field or click the Settings/Preferences button and select the Existing Templates option to see a list of existing templates.

Both

Match case

Select this checkbox if you want PhpStorm to match the case of the code you are searching for.

Both

File type

Use this option to select a file type for your search. In this case, PhpStorm searches only in the specified file types.

Both

the Filter icon

Click this icon to add filters for the whole search template. Use the Add icon to add a new filter or the Remove icon to remove the existing one.

Both

the Settings/Preferences icon

Click this icon to select one of the following options:

  • Save Template: use this option to save a template you have specified in the search template area. PhpStorm adds the saved template to the User Defined node in the Existing Templates dialog.

  • Export Template to Clipboard: use this option to export the template and share it.

  • Import Template to Clipboard: use this option to import the shared template.

  • Existing Templates: use this option to see the list of existing templates.

    In the Existing Templates dialog, select one of the pre-defined or custom templates. The selected template is displayed in the Preview field. When you click OK, PhpStorm inserts the source code of the template into the Search template or Replace template field.

  • Switch to Search/Switch to Replace: use this option to quickly switch to the Structural Search or the Structural Replace dialog.

Both

Replacement template

Use this text area to specify the template to be substituted. You can type the template code in the field or click the Settings/Preferences button and select the Existing Templates option to see a list of existing templates.

Structural Replace

search

Click this icon to see the list of your previous searches.

Both

Shorten fully qualified names

This option makes sense in case the template text contains fully qualified class names. If the checkbox is selected, PhpStorm automatically reduces these names in the template. Otherwise, fully qualified class names are used.

Structural Replace

Reformat

Check this option, if you want PhpStorm to automatically reformat the expanded code fragment according to your code style settings (for details, refer to the Code Style dialog). If the option is not checked, PhpStorm will only indent the whole template according to the position in code at which it is expanded, leaving its formatting as is.

Structural Replace

Use static imports

Check this option, if you want PhpStorm to shorten any references to static elements in the replaced code. PhpStorm will insert a static import for those elements. The elements are then referenced by their short name. If there are no references to static elements in the replaced code, the option will be ignored.

Structural Replace

In

Use this area to specify where PhpStorm should search for and replace your code.

You can select from the following options:

  • Project: when you select this option, PhpStorm searches and replaces the specified template in the whole project.

  • Module: when you select this option, PhpStorm searches and replaces the specified template in the selected module.

  • Directory: when you select this option, PhpStorm searches and replaces the specified template in the selected directory.

  • Scope: when you select this option, PhpStorm searches and replaces the specified template in a certain scope that you have selected. You can select a predefined scope from the available list or create a custom scope when you click the Browse button.

Both

Search target

Use this option to specify the target of your search process which could be the exact match of the template you have specified (Complete match) or just a part of it. The options of the search target depend on the file type you have selected.

Both

Open in new tab

If this checkbox is selected, the results of the new search display in a new tab in the Find results tool window. Otherwise, the search results update the existing tab.

Both

Last modified: 14 September 2021