PhpStorm 2016.1 Help

Finding and Replacing Text in File

The standard facility helps you find and replace text strings in the active editor.

In this section:

Search in the current file

To find a text string in the current file

  1. On the main menu, choose Edit | Find | Find, or press Ctrl+F. The search pane appears on top of the active editor.
  2. If necessary, specify the search options.
  3. In the search field, start typing the search string:
    img

    As you type, the first occurrence of the search string after the current cursor position is selected; the other occurrences are highlighted in the editor. In addition, the matching occurrences are marked in the right gutter with stripes.

    img
    "
  4. Explore search results.

Replace in the current file

To replace a text string in the current file

  1. On the main menu, choose Edit | Find | Replace, or press Ctrl+R. The search and replace pane appears on top of the active editor.
  2. If necessary, specify the search and replace options.
  3. In the search field, start typing the search string. As you type, the matching occurrences are highlighted in the editor, and a Replace pop-up dialog box opens at the first occurrence, suggesting you to replace the current occurrence, or all of them, with an empty string.
  4. Start typing the replacement string.
  5. Explore search results, and, using the buttons of the replace dialog box, replace occurrences as required. See Search and replace options below.

Working with search results

  • To initiate a new search, do one of the following (depending on the current focus):
    • If the editor has the focus, press Ctrl+F.
    • If the search field has the focus, press Ctrl+A

    In both cases, the existing search string will be selected, and you can start typing a new one.

  • To jump between occurrences, do one if the following:
    • Press Shift+F3(jump to previous selection) or F3 (jump to next selection).
    • Use img or img buttons in the Search pane.
    • Click the gutter stripes.
  • The search pane shows the number of found occurrences. If no matches are found, the search pane is red highlighted:
    findResultsNil
  • Use Code completion in Find and Replace panes. Start typing the search string, press Ctrl+Space, and select the appropriate word from the suggestion list.
  • Use the recent history of searches: with the search pane already open, click find1 to show the list of recent entries.
  • With the search or replace pane already opened, use Ctrl+R or Ctrl+F to toggle between panes. So doing, the search and replace strings are preserved.
  • To cancel operation and close the pane, press Escape.
  • Use multiple selection. For example, if a certain string has been highlighted as a search result, it is possible to add an occurrence of this string to the multiple selection by clicking add_selection_icon (Alt+J), delete an occurrence from the multiple selection using remove_selection_icon (Shift+Alt+J), or add all the found occurrences to the multiple selection using select_all_occurrences_icon (Ctrl+Shift+Alt+J).

Search and replace options

ItemDescriptionSearch/Replace
find1Click this button to show the history of the recent entries.Search, replace
closeBlackClick this button to clear the search field.Search, replace
arrowUp arrowDownClick these buttons to navigate through the occurrences of the search string.Search, replace
add_selection_iconClick this button to add the next found occurrence to a multiple selection.Search
remove_selection_iconClick this button to remove the found occurrence from a multiple selection.Search
select_all_occurrences_iconClick this button to create a selection that contains all the found occurrences.Search
exportToTextFileClick this button to show search results in the Find tool window.Search, replace
Match CaseIf this check box is selected, PhpStorm will distinguish between upper and lowercase letters while searching.Search, replace
Regex If this check box is selected, the search string will be perceived as a regular expression, and the replacement preview is shown in a tooltip ( Refer to the section Example). Search, replace
Wordsif this check box is selected, PhpStorm will 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.
Search, replace
Preserve CaseIf this check box is selected, PhpStorm 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 Regular expressions check box is selected.
Replace
In SelectionIf this check box is selected, search and replacement will be confined to the selected text only.Replace
ReplaceClick this button to replace the current occurrence and proceed to the next one.Replace
Replace allClick this button the replace all found occurrences in the current file, or in the selection.Replace
Exclude/IncludeClick Exclude button to skip the current occurrence and exclude it from the Replace all operation. The button for this occurrence changes to Include.Replace
cogwheel_blueClick this button to reveal the list of additional options. Checking the corresponding option confines the search to the specified scope, while the other occurrences are ignored. Search, replace

See Also

Last modified: 12 July 2016