IntelliJ IDEA 14.0.0 Web Help

Structural Search and Replace - General Procedure

This section outlines the general SSR procedure. Refer to the section Structural Search and Replace Examples for typical use cases.

To find and replace source code structurally

  1. On the main menu, choose Edit | Find | Search Structurally , or Edit | Find | Replace Structurally . Alternatively, use keyboard shortcuts StructuralSearchPlugin.StructuralSearchAction or StructuralSearchPlugin.StructuralReplaceAction respectively.
  2. In the dialog box that opens, define the search template. In brief, defining a search template involves the following steps:
    • Type the desired construct in the Search template text area, or use one of the pre-defined search templates by clicking the Copy existing template button.
    • Specify the constraints to be imposed on the variables within the search template. To do that, click the Edit variables button. All the variables contained in the search template are listed in the Variables pane of the Edit Variable dialog box.

    Refer to the section Creating and Editing Search Templates for the detailed description of procedure.

  3. In case of the structural replace, specify the replacement pattern, and define variable constraints as required.
  4. Specify the search and replace options, in particular, the number of occurrences to be matched, and the type of files (Java, XML or HTML) to be analyzed.
  5. Specify the scope to perform the structural search and replace in. To do that, click the down arrow in the Scope list, and select one of the pre-defined scopes, or click the ellipsis button, and configure the desired scope in the Scopes dialog box.
  6. Click Find. The detected occurrences are displayed in the Find tool window.

    Please note the following:

    • In case of replacement, you can select the desired matches in the search results and click the Preview Replacement button. The corresponding occurrence is highlighted in the source code.

See Also

Last modified: 12 November 2014
comments powered by Disqus