IntelliJ IDEA Tips: Keyboard Shortcuts and Tricks for Efficient Java Development
This article presents a collection of practical IntelliJ IDEA shortcuts and techniques—including custom key bindings, navigation shortcuts like ctrl+alt+h, alt+f7, and ctrl+shift+a—to help Java developers efficiently explore code, locate methods, manage tabs, and improve overall productivity within the IDE.
Overview
Previously I wrote an article listing some rarely used but very handy IntelliJ IDEA tricks. Because of length limits only a few were shown, so this article continues to add more IntelliJ IDEA tips.
Don’t Define Custom Shortcuts Lightly
Many operations in IntelliJ IDEA have no default shortcuts, so users must define them, e.g., Rebuild Project, Compare With Branch.
Shortcut conflicts with other applications may occur.
Too many custom shortcuts are hard to remember.
When using a colleague’s IDE, your custom shortcuts won’t work.
Every action in IntelliJ IDEA can be invoked via Ctrl+Shift+A . For example, type Rebuild Project after pressing Ctrl+Shift+A and hit Enter to execute.
Use Ctrl+Alt+H Carefully
Ctrl+Alt+H is useful but has a pitfall: when a method is called multiple times, the tool only shows the call hierarchy, not each individual call. For instance, in the code below, Ctrl+Alt+H tells you that test3() calls test1() twice, which can mislead developers.
public class TestService {
public void test1() {
System.out.println("aa");
}
public void test2() {
test1();
}
public void test3() {
test1();
// many business operations, then call test1() again
test1();
}
}To list the exact call sites of test1() , use Alt+F7 instead of Ctrl+Alt+H .
How to Jump to Source Code from Ctrl+Alt+H
After invoking Ctrl+Alt+H , select a call with the arrow keys and press F4 to open the source.
How to Return to the Ctrl+Alt+H View
When you have jumped to source with F4 , press Alt+8 to go back to the hierarchy view.
Quickly Find Controller Methods
If your project contains many controllers with numerous HTTP or RESTful methods, use Ctrl+Alt+Shift+N and type part of the URL (e.g., /bill ) to locate the method instantly.
Bookmark Key Business Methods
In startups, core modules (order, payment, product) often reside in the same project. Use Bookmark to collect important business methods for easy navigation.
How to Add a Method to a Bookmark
Press Ctrl+F12 to list all methods in the class, type the method name (e.g., test1 ) and place the cursor on it.
Press F11 to add the method to a bookmark.
Press Shift+F11 to show the bookmark list.
Press Ctrl+Enter to rename the bookmark.
Keep Only One Code Tab
Configure the IDE to use a single tab for all files. Press Ctrl+Shift+A , type Editor Tabs , go to the settings page, and set Placement to None . Use Ctrl+E to view recent files.
How to Read Long and Messy Code
Use five small tricks in IntelliJ IDEA to improve reading speed and quality.
Create Arbitrary Code Folding Blocks
Place the cursor inside a block (e.g., a for loop) and press Ctrl+Shift+. to fold it. Press Ctrl + + to unfold.
Brace Matching
Position the cursor on a brace and press Ctrl+] or Ctrl+[ to jump to its matching brace.
Ctrl+Shift+F7 Combined with F3
Ctrl+Shift+F7 highlights a variable persistently; then use F3 to navigate to the next occurrence.
Use Ctrl+Shift+I
Press Ctrl+Shift+I to pop up a quick definition window for the symbol under the cursor (e.g., class TestTemp ). Press Esc to close.
Use Alt+F7
Lists all places where a variable is used.
Jump to Parent Interface
When implementing an interface (e.g., UserService ), place the cursor on the implementation method and press Ctrl+U to navigate to the interface declaration.
Undo/Redo (The “Regret Medicine”)
Press Ctrl+Z to undo recent changes; press Ctrl+Shift+Z to redo them.
Fastest Way to Switch Theme
Press Ctrl + ` (back‑tick) to open the “Switch Theme” dialog, choose Color Scheme , and press Enter.
Like the Article
If you find this article helpful, please give it a like.
Original source: blog.csdn.net/linsongbin1/article/details/80560332
Java Captain
Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.