PhpStorm 2019.2 Help

Finding and replacing text in 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.

  1. Open your file in the editor.

  2. From the main menu, select Edit | Find | Find Ctrl+F.

  3. In the search field that opens, enter your search string. PhpStorm highlights the results of your search in the file. Alternatively, in the editor, highlight the string you want to find and press Ctrl+F. PhpStorm places the highlighted string into the search field.

    search string

See the usages of a symbol in the current file

Position the caret at a symbol and press Ctrl+F7. PhpStorm displays all the usages of the symbol in the file.

In the PHP context, PhpStorm automatically highlights extended and implemented methods, import statements, exit points, the places where exceptions are thrown, and loop statements. Highlighting is invoked when you place the caret at an extends, implements, use, use trait, return, try, catch, @throws, break, or continue keyword.

Symbols' usages are highlighted with regard to their scope. For example, highlighting for @throws is not applied inside nested classes and functions.

Highlight Usages in File

To turn off this highlighting, in the Settings/Preferences dialog (Ctrl+Alt+S), go to Editor | General and clear the Highlight usages of element at caret checkbox.

Manage your search

PhpStorm lets you adjust your search process and perform various actions with the displayed search results.

  • If you want to see the list of previous searches, press ⌥↓ in the search field.

    search history

  • If you want to enter a multi-line string, click the Enter a new line icon in the search field for a new line.

  • Use the Previous occurence and Next occurence arrows to navigate to the previous or the next occurrence.

  • 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

  • Click the Add selection for the next occurence or deselect the previous occurrence icon to add a selection of the next occurrence or deselect the previous occurrence Alt+J or Shift+Alt+J.

  • If you want to quickly replace the target of your search in the whole file, press Ctrl+Shift+Alt+J and type a new string.

  • You can narrow your search when you select the Words, Match case checkboxes on the search pane, or click the filter filter icon to select a scope for your search.

  • You can press ⌥X (previously known as ⌥G) to quickly select or clear the Regex checkbox. You can use regular expressions to opt 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: 23 September 2019