4 minutes read

It is pretty hard to remember all the shortcuts and all the actions and productivity boosters IntelliJ IDEA has. However, don't worry about that. All you need to remember is the one action that rules them all, Help | Find Action command (⌘ ⇧ A / Ctrl + Shift + A). Just start typing the action you need, and you will get the list:

IntelliJ IDEA lets you find and replace text strings in an active editor.

Search through the current file

  • From the main menu, choose Edit | Find | Find, or press ⌘ F / Ctrl + F. The search panel appears at the top of the active editor.

  • If necessary, specify the search options.

  • In the search field, start typing the search string:


    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.

  • To search for a multi-line fragment, click in the search box.

  • Explore the search results.

Replace in the current file

  • From the main menu, choose Edit | Find | Replace, or press ⌘ R / Ctrl + R. The search and replace pane appears on top of the active editor.

  • If necessary, specify the search and replace options.

  • 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 to replace the current occurrence, or all of them, with an empty string.

  • Start typing the replacing string.

  • Explore the search results, and, using the buttons of the replace dialog box, replace occurrences as required.

See Manage your search page for the detailed description of search and replace options.

Navigate commands enable you to quickly jump to the desired classes, files, or symbols specified by names. IntelliJ IDEA suggests a look-up list of matching names, from which you can select the desired one, and open it in the editor. This navigation honors CamelCase and snake_case capitalization. Refer to the tips for the detailed list of available techniques.

Declaration and list of usages

Programming is much more about understanding and reading existing code than about writing some new code. While learning, it is also quite important to see your code as a whole and to understand how it works.

When you use any variable, function, or method and need a tip on how it works, let the code speak for itself. Take a look at the definition with ⌘ Y / Ctrl + Shift + I:

There's one more option: press ⌘ B / Ctrl + B to navigate to the declaration of an entity; use it one more time on the declaration to see the list of usages:

On the main menu, point to Navigate, and then choose Class, File, or Symbol respectively, or use the following shortcuts:

  • Class: ⌘ O / Ctrl + N

  • File (directory): ⌘ ⇧ O / Ctrl + Shift + N

  • Symbol: ⌘ ⌥ O / Ctrl + Shift + Alt + N

  • In the pop-up window, start typing the desired name. So, you can enter characters located anywhere inside the desired name. As you type, the suggestion list shrinks, displaying the matching names only.

    • Class:


      You can also navigate directly to a specified anonymous class. It is enough to specify the class name and the anonymous class number, delimited with $ character:

    • File:

    • Directory: use the same shortcut as for file navigation, and type the name of the directory you are looking for, the pattern name ending with / or \:

    • Symbol:

  • Click the desired entry in the suggestion list, or select it using the arrow keys, and press Enter.

Conclusion

You can easily find and replace text strings as well as navigate through your code using these simple commands and hotkeys. Don’t forget this feature while using IntelliJ IDEA to boost your efficiency and save time.

311 learners liked this piece of theory. 6 didn't like it. What about you?
Report a typo