PyCharm 2019.1 Help

Structural Search and Replace Dialogs

Edit | Find | Search Structurally
Edit | Find | Replace Structurally

Use these dialog boxes 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 to be sought for. You can type the template code in the field or click the Existing Templates button to see a list of existing templates.

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 Existing Templates button to use one of the existing templates.

Structural Replace

Save Template

Click this button to open the Save Template dialog box, where you have to specify the name of the new template. Note that the new template is stored under the User Defined node of the existing templates tree view.

Both

Edit filters

Click this link to add filters.

Both

History

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

Both

Existing Templates

Click this option to open the Existing Templates dialog, where you can select one of the pre-defined or custom templates. Selected template is displayed in the Preview field. Clicking OK in the Existing Templates dialog inserts the source code of the template into the Search template or Replace template field.

Both

Recursive

If this checkbox is selected, the search is performed recursively in the results.

Structural Search

Case sensitive

If this check box is selected, the search discerns lower and upper case letters.

Both

File type

Select file type from the drop-down list.

Both

Shorten fully qualified names

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

Structural Replace

Reformat

Check this option, if you want PyCharm to automatically reformat the expanded code fragment according to your code style settings (for details, refer to the Code Style dialog box). If the option is not checked, PyCharm 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 import

Check this option, if you want PyCharm to shorten any references to static elements in the replaced code. PyCharm 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

Scope

Select one of the existing scopes from the drop-down list or click the ellipsis button (alternatively, press Shift+Enter), and create your own scope in the Scopes dialog box.

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: 17 July 2019

See Also