WebStorm 2020.3 Help

Search Templates

When you construct a template for a structural search you are basically writing a script. To simplify your scripting process, WebStorm offers you a list of predefined search templates that you can use as prototypes for your search template.

Search templates dialog

On how to access the list of the existing search and replace templates, see the structural search and replace section.

A valid search or replacement template represents one of the following supported languages constructs:

  • Expression, for example "John" + " " + "Doe"

  • Statement, or sequence of statements, for example document.getElementById("demo").innerHTML = "Hello Dolly.";

  • Class designator, for example class Engine implements IEngine

  • Line or block comments, for example /** Created in WebStorm */.

In search templates, the following simplifications can be used:

  • Method body can be omitted.

  • Short class names (instead of fully qualified names) are used in the templates and constraint fields.

  • Using class $Class$ as a template results in finding anonymous classes as well.

  • Templates for comments and documentation comments should contain variables and constructs with correct comment and JSDoc syntax.

Each search or replace template consists of variables $variable_name$ to which you can add a condition (filter) to narrow your search results. Filters depend on a variable in your search template.

Last modified: 08 March 2021