RubyMine 2018.3 Help

Structural Search and Replace

A conventional search process does not include the syntax and semantics of the source code. Even if you use regular expressions, RubyMine still treats your code as a regular text. The structural search and replace (SSR) actions let you search for a particular code pattern or grammatical construct in your code considering your code structure.

RubyMine finds and replaces fragments of source code, based on the search templates that you create and conditions you apply.

To find and replace source code structurally

  1. On the main menu, choose Edit | Find | Search Structurally, or Edit | Find | Replace Structurally.

  2. In the dialog box that opens, define the search template.

  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 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 that 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.

Last modified: 6 December 2018