IntelliJ IDEA 2018.3 Help

Replace the found target

If you need to replace the search string you can either use the Replace in file or Replaces in Path actions. You can also use the Rename Refactorings.

On how to use regex with replace, refer to the find and replace with regex section.

Replace the search string in a file

  1. Press Ctrl+R or 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 the Multi-line icon for a multi-line replace. For example, if you want to replace a comma with a coma 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.

Replace the search string in a project

  1. Press Ctrl+Shift+R to open the Replace in Path dialog.

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

    Replace in path dialog
    For example, if you want to replace a variable name with a new name for a large project, use the replace in path instead of rename refactoring since your variable can appear in the config files as well.

  3. Click one of the available Replace commands.

Last modified: 1 February 2019