Search for a target within a file
You can quickly find and replace text strings in the current document. Using different options, you can narrow your search process, use regular expressions in your search, and manage your search results.
Open your file in the editor.
Press Ctrl0F or select Edit | Find | Find from the main menu.
note
To search for your target in the whole project, press CtrlShift0F. For more information, refer to Find your target in a project.
In the search field that opens, enter your search string. WebStorm highlights the results of your search in the file.
Vice versa, when you highlight a string in the editor and press Ctrl0F, WebStorm places the highlighted string into the search field.
Alternatively, just place the caret at the string to search and press Ctrl0F or select Edit | Find | Next Occurrence of the Word at Caret from the main menu.
You can search for a text string inside a multi-line selection.
note
WebStorm handles replacing in multi-line selections the same way.
Press Ctrl0F and select a multi-line fragment.
Click
, set a tick next to Search In Selection and type your search string. WebStorm will search for the target inside the selected fragment first.
If you remove the tick next to Search In Selection, WebStorm will switch the search process back to the whole file.
GifIf you want to search for the multi-line fragment itself, select it and press Ctrl0F.
To see the list of previous searches, press ⌥+↓ or click
in the search field.
To enter a multi-line string, click the
icon in the search field for a new line.
With
selected, WebStorm automatically escapes special regex symbols with backslash
\
when you search for a text string that contains them.note
Keep in mind that if you copy (Ctrl0C) the string first and then paste (Ctrl0V) it in the search field, the regex symbols will not be taken into account.
For more information about regex, refer to the search with regex documentation.
To navigate to the previous or to the next occurrence, use the
and
arrows.
Work with the list of occurrences AltF7 in the Find tool window, where you have other options, for example, to group your results or to open them in a separate window.
GifTo add a selection of the next occurrence or deselect the previous occurrence, click
or
Alt0J or AltShift0J.
To quickly replace the target of your search in the whole file, press CtrlAltShift0J and type the replacement string.
GifTo narrow your search, select the Words or Match case checkbox on the search pane, or click 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.
Press Ctrl0R or select Edit | Find | Replace from the main menu to open the Replace in File window.
In the top field, enter your search string. In the bottom field, enter your replacement string. If you need to preserve the case, click
located in the replace field.
Click
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.
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.
Thanks for your feedback!