WebStorm 2016.2 Help

Find and Replace in Path

Edit | Find | Find in Path or Replace in Path
Ctrl+Shift+F or Ctrl+Shift+R
In the Project tool window: Find in Path or Replace in Path from the context menu for a directory


Specify what you want to find and where. In the Replace in Path dialog, also specify the replacement text or pattern.

Use Ctrl+Shift+F and Ctrl+Shift+R to switch between the find and replace modes.

Search pattern and replacement text

ItemDescription
Text to findIn this field, specify the search pattern. Type the text manually or select one of the previously specified patterns from the drop-down list.
  • If you specify the search pattern through a regular expression, use the $n format in back references (to refer to a previously found and saved pattern).
  • This field can be left empty. If there is no text to find, but the File mask check box is selected, then search results include only the files matching the specified mask.

Pressing Alt+Down in this field, will open a history drop-down list of your previous search entries.

Replace withIn this field, specify the replacement text. Type the text manually or select one of the previously specified substitutions from the drop-down list.
  • If you specify the replacement text through a regular expression, use the $n format in back references.
  • To use a backslash character \ in a regular expression, escape the meaningful backslashes by inserting three extra backslashes in front: \\\\.

This field is available only in the Replace in Path dialog.

Options

Use this tab to specify find and replace options.

ItemDescription
General In this area, specify additional search and replace parameters. The available options are:
  • Case sensitive - select this check box to have WebStorm distinguish between upper and lowercase letters while searching.
  • Preserve case - if this check box is selected, WebStorm retains the case of the first letter and the case of the initial string in general. For example, MyTest will be replaced with Yourtest if you specify yourtest as the replacement.

    This check box is disabled, if the Case sensitive or Regular expressions check box is selected.

    This field is available only in the Replace in Path dialog.

  • Whole words only (may be faster) - select this check box to have WebStorm search for whole words only, that is, for character strings separated with spaces, tabs, punctuation, or special characters.

    This check box is disabled, if the Regular expressions check box is selected.

  • Regular expressions - select this check box if the specified search pattern should be treated as a regular expression.
  • Context - use this drop-down list to confine the search to a certain context, for example:
    • anywhere - select this option to search everywhere.
    • In comments - select this option to confine search to comments, ignoring the other occurrences.
    • In string literals - select this option to confine search to string literals, ignoring the other occurrences
    • Except... - select one of the exception options to perform search avoiding comments, string literals or both.
ScopeIn this area, specify the scope to apply the search to. The available options are:
  • Whole project - select this option to search through the entire project.
  • Directory - select this option to perform search within the specified directory. By default, the text area already contains the directory name where a file currently opened in the editor is located (if you call the dialog from the editor), or where a file selected in the tool window is located (if you call the dialog from the tool window), or the directory name selected in the tool window.

    Pressing the ellipsis button opens the Select Path dialog, where you can select the necessary directory.

  • Recursively - this check box is only available for the directory search. If selected, sets the search to be performed in the chosen directory and its subdirectories.
  • Custom - select this option to search in a scope.

    You can choose one of the scopes from the drop-down list, or click the ellipsis button, and define a new scope in the Scopes dialog.

File name filterIn this area, specify additional settings to narrow down the search scope.
  • File mask - select this check box to narrow down the search scope through file masks. In the drop-down list, select the desired mask or specify a new one using wildcards.

    Wildcards can include:

    • * to substitute a set of any characters,
    • ? to substitute a single character,
    • ! to exclude files. Mind that ! should go first in a particular file name pattern, for example, !*.gant

    You can specify multiple file masks, delimited with commas (for example, *.xml,a?c.sql,!*.html).

    Note also, that negated pattern (for example, !*.min.js) has implicit inclusion pattern *. This allows avoiding such constructs as *, !*.min.js for every file except minified javascript).

If text to find is not entered, and this check box is selected, then WebStorm find all files matching the specified mask, regardless of their contents.

Result optionsClick the down arrow to reveal the result presentation options.
  • Skip results tab with one usage - Select this check box to be navigated directly to the found string in the editor, when only one usage is found.

    The check box is available only in the Find in Path dialog box.

  • Open in new tab - If selected, sets the search results to be displayed in a separate tab.
Find
  • When you click this button in the Find dialog box, WebStorm displays the encountered occurrences of the search string in the Find tool window, selects the first occurrence and opens the file with this occurrence in the editor and moves the focus to it.
  • When you click this button in the Replace dialog box, WebStorm displays the encountered occurrences of the search string in the Find tool window, selects the first occurrence and opens the file with this occurrence in the editor and moves the focus to it.

    At the same time, WebStorm opens the Replace Usage dialog box, with the full path to the encountered occurrence in the title bar:

    ws_replace_usage

    Do one of the following:

    • To have the selected occurrence replaced, click Replace.
    • To preserve the selected occurrence and move to the next one, click Skip.
    • To have all the occurrences of the search string in the currently active tab replaced, click Replace All in This File.
    • To preserve the occurrences of the search string in the currently active tab (any) and move to the next file, click Skip to Next File.
    • To have all the detected occurrences replaced, click All Files.
    • To switch to the manual mode, click Preview. The Replace Usage dialog box closes and the focus moves to the Find tool window. Do one of the following:
      • Browse through the list of detected occurrences, select the ones you want to replace and then click Replace Selected.
      • To have all the occurrences changed click Replace All.

Preview

Use this tab to check the preview of your search target.

You can press Up or Down keys to navigate between entries in the preview area without leaving the Text to find field. You also can press F4 to get to the selected entry in the editor.

See Also

Last modified: 15 November 2016