Eclipse Short Cut
Eclipse Short Cut
But who has time to memorize every single package path for every single class in every single
library? You can let Eclipse handle it for you using the Ctrl + Shift + O shortcut, which automatically
imports unrecognized classes in code.
Instead of typing import lines by hand, you can just write code as normal until you see the red
squiggly lines (indicating unrecognized classes), then hit the Organize Imports shortcut.
import java.util.ArrayList;
Maybe you wrote it that way, or maybe you copy-pasted from elsewhere. Either way, the good news
is that Eclipse makes it trivially easy to fix: highlight the portion of code that’s hard to read, then use
the Ctrl + I shortcut to instantly bring it to proper indentation.
3. Delete Current Line (Ctrl + D)
When coding in Java, it’s natural to remove entire lines of code at a time. The worst way to do this?
Highlight with the mouse, then hit Backspace. The rookie way to do this? Hit the End key, hold Shift,
hit the Home key, then Backspace. But the pro way? Simply hit Ctrl + D.
Here’s what you do instead: type the first few letters of the class, method, or variable you want,
then hit Ctrl + Space. This brings up a list of autocompletion recommendations along with method
signatures, variable types, and more. Select the right one, hit Enter, and keep coding.
The best part? The cursor is immediately placed within the method call’s parentheses, so you start
typing the message right away:
6. Search Entire Project (Ctrl + H):
When working on large codebases, it’s easy to forget where you declared certain classes, methods,
or variables. Instead of wasting time combing through directories by hand, use the Search Entire
Project prompt with the Ctrl + H shortcut.
By default, it comes with four search types: File Search, Task Search, Git Search, and Java Search.
You’ll mostly use Java Search, which only searches through source files, but the other three can be
useful in their own ways.
Or you can right-click on the name, select Refactor > Rename, type in the new name, and have
Eclipse change every single reference in the entire project in a second. Even faster, you can click on
the name, hit Alt + Shift + R, type in the new name, and hit Enter. Bam, done!
##############