Useful Tips and Shortcuts for Eclipse IDE
Thu, Jul 18, 2013I’ve used several IDEs in combination with many different languages, but the one I’ve felt benefits the most from a lot of user knowledge / tweaking is Eclipse. Now, for this list of tips and shortcuts I’m assuming that you are using Java, but many (if not most) of them are language-independent.
Keyboard Shortcuts:
ALT + SHIFT + L: Local variable extraction of text selection (i.e. makes a new local variable out of the highlighted text and inserts a reference in its place automatically).
ALT + SHIFT + M: Method extraction of text selection (i.e. makes a new method out of the highlighted text and inserts a reference in its place automatically).
ALT + SHIFT + R: Rename. Renames a member and updates every reference. This is incredibly useful as it saves a lot of headaches later that can result from outdated references.
ALT + LEFT or RIGHT: Navigates backward and forward through your action “history”. Very useful for navigating a call stack up and down swiftly.
CTRL + ALT + H: Open Call Hierarchy. Brings up every reference to the highlighted member in your current working set.
CTRL + SHIFT + L: List of all keyboard shortcuts. Press again to edit shortcuts.
CTRL + SHIFT + R: Open Resource. Allows you to quickly navigate to any file by name. This shortcut alone is one of the most important to learn for time-saving. It even “learns”, providing a favorites list that is tuned to each search combination you have used previously.
CTRL + SHIFT + /: Collapse All. It closes all possible blocks of code, useful to skim through your classes swiftly.
CTRL + SHIFT + *: Expand All.
CTRL + J: Incremental find (like seen in a browser or document viewer).
CTRL + K: Finds the next occurrence of the highlighted text.
CTRL + O: Find methods within the current class.
CTRL + Q: Returns to the last edit location (useful for resuming work after interruptions).
F3: Open Declaration. Brings you to where the selected member is declared.
Tips:
Eclipse supports camel case in many of its features, such as autocomplete and open resource. For example, typing RDA and then pressing CTRL + SPACE will autocomplete to RegistrationDataAccess (assuming it is in your working set).
Eclipse can automatically organize your imports on a save, adding necessary imports and removing unneeded imports. This is enabled by navigating via Window->Preferences->Java->Editor->Save Actions.
Clicking on a return type will show all exit points for a method, while clicking on an Exception catch/throw will show all members that can throw that Exception.
The Package Explorer tab has a “Link with Editor” button. Clicking this automatically opens the path the Package Explorer to the current file selected in the Editor. Very useful for finding exactly where the file you are working on is located.
All tabs and toolbars are movable, hideable and flexible size.
The Breakpoints tab can be used to find all of your breakpoints and remove them at once.
The “Skip All Breakpoints” button can be displayed on the toolbar or the Breakpoints tab.
Debug mode + Variables tab watches every variable as it is modified by your code. You can even modify them on the fly, allowing you to see how bad inputs will affect methods even if your code cannot currently provide such input.
You can disable Eclipse’s auto-focus on the Debug tab by navigating to Window->Preferences->Run/Debug and unchecking “Activate the debug view…”.
You can disable Eclipse’s auto-focus on the Console tab by pressing “Show Console When Standard Out Changes”.
You can comment your code.
Links with more tips:
http://stackoverflow.com/questions/54886/hidden-features-of-eclipse
http://stackoverflow.com/questions/20529/useful-eclipse-features