You can use Eclipse’s powerful features smartly while coding using this editor. These tips will help you handle eclipse like a pro and be more productive:
Tip 0: Ctrl + Shift + L -> Displays list of shortcuts.
Tip 1: Changing Font for Code Editor:
Tip 2: Maximizing & Minimizing Opened File.
Tip 3: Shortcut for writing commands (Auto Suggestion Feature)
Tip 4: Auto selection of available option.
Tip 7: Auto format your code while saving a file.
Tip 8: Remove unused imports while saving file.
Tip 9: Comment out block of code.
Tip 10: Check entire hierarchy of the class.
Tip 12: Jump to any particular line.
Tip 13: Move to line you last edited.
Tip 15: Collapse all code blocks.
Tip 17: Jump to Matching Bracket .
Tip 18: Insert main method in a class.
Tip 19: Adding Code around a block of code.
Tip 20: Create Getters & Setters for a class:
Tip 0: Ctrl + Shift + L -> Displays list of shortcuts
Tip 1: Changing Font for Code Editor:
Go to Window -> Preferences -> General -> Appearance -> Colors and Fonts and change colors and fonts for your editor.
Tip 2: Maximizing & Minimizing Opened File
In order to maximize or minimize opened window use Ctrl + M
It will maximize the current view or editor. Press Ctrl+M again and it goes back to the previous size.
Shortcut for Window > Navigation > Maximize Active View or Editor.
Tip 3: Shortcut for writing commands (Auto Suggestion Feature)
Write syso & press Ctrl + spacebar . Click Enter. It will complete the command.
System.out.println(“Hello World”);
Similarly you can write command starting with any letter e.g. write bigd (short for BigDecimal)& then press ctrl + spacebar.
Tip 4: Auto selection of available option
Write starting letters and press Ctrl + 1 and it will show what can be done using these letters.
Tip 5: Alt + Up or Alt +Down
Line Moves Up or down. It works with single line as well as multiple selections of lines.
Tip 6: Debugging
Add/Remove Breakpoint – Just double click at the start of line to toggle breakpoint.
Step Into = F5
To continue executing rest of the program = F8
Change to Debug Perspective and then debug your code. You can also use conditional breakpoints.
Tip 7: Auto format your code while saving a file
You can auto format your code from Window -> Preferences -> Java -> Editor -> Save Actions by selecting appropriate options available here. You can also organize your imports from this window.
The other option that you can also is Ctrl + Shift + F to format the code.
Tip 8: Remove unused imports while saving file
Eclipse can remove unused imports using ctrl+shift+O.
Tip 9: Comment out block of code
Select the block of code and press Ctrl + / and it will comment out the block of code. Press Ctrl + / again and it will remove the comment’s slashes.
Tip 10: Check entire hierarchy of the class
When on a class and you want to check entire hierarchy, press F4. It will show Type hierarchy.
Tip 11: Delete entire line:
If you are on a line and press Ctrl + D it will delete the whole line.
Tip 12: Jump to any particular line
If you want to jump to any particular line, press Ctrl+L and then enter line number.
Tip 13: Move to line you last edited
Press Ctrl + Q and it will take you to the line you last edited.
Tip 14: Rename the class
Press Alt + Shift + R and it will Rename the class.
Tip 15: Collapse all code blocks:
There is a hotkey that is mapped by default to Ctrl+Shift+NUM_KEYPAD_DIVIDE.
You can change it to something else via Window -> Preferences, search for “Keys”, then for “Collapse All”.
To open/expand all code blocks the shortcut is Ctrl+Shift+NUM_KEYPAD_MULTIPLY.
Alternatively you can also use below approach if you don’t have Num_KeyPad:
Right click on the +/- sign and click Folding -> collapse all or expand all.
Tip 16: Fix Keyboard Setup:
If accidently your keyboard setup messes up in Eclipse and it starts typing characters that you didn’t intent to type, you can get back to your keyboard layout by pressing “Alt + Shift” in eclipse,
Tip 17: Jump to Matching Bracket
To jump to the matching bracket for a loop in Eclipse IDE select opening or closing bracket and use Ctrl + Shift + P.
Tip 18: Insert main method in a class
To insert main method in a class, you can type ‘ma’ and press Ctrl+Space then select main method from displayed list.
Tip 19: Adding Code around a block of code
Select a block of code and press Alt+Shift+Z to see options that can enclose the selected block of code.
Tip 20: Create Getters & Setters for a class:
Click on Source → Generate Getter and Setter to open the wizard that will allow you to generate getter and setter methods.
Please comment with your real name using good manners.