IntelliJ IDEA 2018.1 Help

Finding and Replacing Text in Project

IntelliJ IDEA extends search and replace capability to the entire project, specific module, or any directory with its nested hierarchy. Explore search results in the preview tab or in the Find tool window.

To find a piece of text in all files with the specified path

  1. On the main menu, choose Edit | Find | Find in Path, or press Ctrl+Shift+F.
  2. In the Find In Path dialog, specify the following options:
    • Start entering the text. Type the text explicitly, or specify a pattern using a regular expression, or select a previously used piece of text or a pattern from the recent entries' 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).

    • Search scope ( project, module, directory, or custom scope).
      search scope
    • Search options (case sensitivity, whole words, and regular expressions).
      search options
    • Context search options.
      context search
    The results are displayed in the preview area.

To replace a piece of text in all the files within the specified path

  1. On the main menu, select Edit | Find | Replace in Path (Ctrl+Shift+R).
  2. In the Replace In Path dialog, specify the search and replace strings, the search options, and the scope. Type the search and replacement text explicitly, or specify patterns using regular expression, or select a previously used piece of text or a pattern from the recent history drop-down list.
    • If you specify the search and/or replacement text through a regular expression, use the $n format in back references (to refer to a previously found and saved pattern).
    • To use a backslash character \ in a regular expression, escape the meaningful backslash by inserting three extra backslashes in preposition: \\\\.
  3. Click Open in Find Window (Ctrl+Enter) to open a Find tool window with the list of encountered occurrences and a preview of the occurrences alongside.
  4. Preview items you want to replace and click Replace All to replace all detected occurrences or Replace (Alt+Enter) to replace items one by one.
    replace occurrences
    To return to the Replace in Path dialog, press Ctrl+Shift+R or click the settings icon located in the Find tool window.

Toggle between the Find and Replace

  1. To switch from the Find In Path to Replace In Path window, press Ctrl+Shift+R.
  2. To switch from the Replace In Path to Find In Path window, press Ctrl+Shift+F.
Last modified: 24 July 2018

See Also