Control + Shift + O: Import
If you’re going to use ArrayList, LinkedList or any other such data structure class from the Java Collections Framework, you will need the following lines above your class declaration and constructor.import java.awt.List;
import java.util.ArrayList;
public class Hello {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Control + I: Indent
Is your code looking like this at times?Control + D: Delete Line
If you need to delete a line, you might usually highlight the entire line with your mouse (or with the Home or End buttons) and delete the new line character every time. Try Ctrl + D for quick whole-line deletion. It will be like the line was never even there, no final new line character touchups necessary.Control + Space: Auto-Complete Variable Or Function Name
If you have declared and initialized at least one variable or even function or method, you can type the first few letters of the variable or function name, hit Ctrl + Space to auto-complete it. This will work well if you have very unique variable or function names, because otherwise, you’ll have to choose among the distinct names in a focus popup window.Sysout + Control + Space: Puts System.out.println()
If you ever need to type out a print statement, in particular, “System.out.println()”, there’s a shortcut for this: Simply type out the word “sysout” and then hit Ctrl + Space.Control + H: Search Your Entire Project
When you’re working on projects with numerous classes that rely on each other, sometimes you might forget where it was you declared a specific function or variable. If that’s the case, Ctrl + h will come in handy as it lets you search through not just the class you’re working on, but the entire project folder.Control + F11: Run
If you’re constantly pressing on Run As > Java Application, you can instead press on Ctrl + F11 to run your program.Alt + Shift + R: Rename
When you want to rename a variable or a function, you don’t have to re-type every single instance of the old variable or function name, nor do you have to right-click on the name and select Refactor > Rename when you can simply press Alt + Shift + R to rename ALL the instances.
Some more .....
- Control + L is Go To Line Number
- F3 takes you to the declaration of a function or variable
- CTRL+SHIFT+T : open fast type browser – start typing your class name
to filter the list (also accepts wildcards, like *StuffFacade) then use
the up-down cursor keys to open the type.
- CTRL+SHIFT+R : open fast file browser – like the above, but for files, so its useful when developing non-Java code.
- CTRL-O : fast outline browser – to jump to a method, hit they keys
then start typing the method name until the list is small enough so you
can up-down to the required method.
- ALT-F8 : switch between perspective in a LRU manner (like ALT-TAB for applications)
- F12 : go to editor – if your keyboard focus is in any other view, move
the keyboard to the editor view. Also, ALT-SHIFT-Q opens a fast list of
all viewes you can access with a keyboard shortcut (that is in the
default form of ALT-SHIFT-) so you can easily switch to the required
view without remembering the actual shortcut.
- CTRL-E : open a fast list of editor tabs (including those not visible
in the tab bar, which are marked in bold) to easily find the editor tab
you need. This list also supports type-to-filter.
- ALT-Up/ALT-Down : move the current line (or lines selected) in the
editor up or down one line while fixing indentation (so moving the line
into an indented block will indent the line correctly). Very useful for
quick refactoring.
- F2 : Quick Javadoc – opens a floating dialog with the javadoc for the
symbol the cursor is on. Use up-down to browser the documentation and
ESC to dismiss.
- Ctrl-/ : Highlight block of code to comment it out.