WebStorm 2019.3 Help

Search for a target within a file

You can search for a text string in a currently opened file in the editor. Using different options, you can narrow your search process, use regular expressions in your search, and manage your search results.

Find the search string in a file

  1. Open your file in the editor.

  2. Press Ctrl+F or select Edit | Find | Find from the main menu.

  3. In the search field that opens, enter your search string. WebStorm highlights the results of your search in the file.

    search string

    Vice versa, when you highlight a string in the editor and press Ctrl+F, WebStorm places the highlighted string into the search field.

    Alternatively, just position the caret at the string to search and press Ctrl+F or select Edit | Find | Find Word at Caret from the main menu.

Find in selection

You can search for a text string inside the multi-line selection.

  1. Select a multi-line fragment and press Ctrl+F.

  2. Enter your search string. WebStorm will search for the target inside the selected fragment first.

    If you press Ctrl+F again or click the In Selection button, WebStorm will switch the search process back to the whole file.

    If you want to search for the multi-line fragment itself, select it and press Ctrl+F twice or double-click the In Selection button.

Manage your search

  • To see the list of previous searches, press ⌥+↓ in the search field.

    search history
  • To enter a multi-line string, click the Enter a new line icon in the search field for a new line.

  • To navigate to the previous or to the next occurrence, use the Previous occurence and Next occurence arrows.

  • Work with the list of occurrences Alt+F7 in the Find tool window, where you have other options, for example, to group your results or to open them in a separate window.

    Found Occurrences in the Find tool window
  • To add a selection of the next occurrence or deselect the previous occurrence, click Add selection for the next occurence or deselect the previous occurrence Alt+J or Shift+Alt+J.

  • To quickly replace the target of your search in the whole file, press Ctrl+Shift+Alt+J and type the replacement string.

  • To narrow your search, select the Words or Match case checkbox on the search pane, or click filter Filter and select a scope for your search.

  • To quickly select or clear the Regex checkbox, press ⌥X (previously known as ⌥G). Use regular expressions for more challenging searches.

Replace the search string in a file

  1. Press Ctrl+R to open the Replace in File window.

  2. In the top field, enter your search string. In the bottom field, enter your replacement string.

    Replace in file pane

    Click Multi-line for a multi-line replace. For example, if you want to replace a comma with a comma and a new line, enter a comma in the search field and a comma and the new line in the replace field.

  3. Click Replace to replace items one by one, Replace all to replace all items in your file, and Exclude to omit some items from replacing.

The options that appear in the Replace window, are similar to the Find window and you can refer to the manage the search results section.

Last modified: 17 February 2020