Introduction to Eclipse
I’ve been a die-hard vi programmer for years, and become quite proficient at using the editor. But a couple of my co-workers have continued touting the merits of Eclipse, until I gave in and gave it a try. At first I only used it for a couple hours at a time, with weeks in between. But my usage has continually increased, until now I’m starting to prefer it for some tasks. Eclipse has about a gazillion keyboard shortcuts; here are the ones I find most useful.
Code Manipulation
ctrl + /- Toggle comment. Comments or uncomments the selected lines.
ctrl + space- Code Assist. Presents a list of suggested completions for the current word.
alt + /- Content Assist. Completes the current word using Eclipse’s best guess based on the context.
alt + /again cycles through the suggestions. ctrl + 1- Quick fix. Hit this while your cursor is over a squiggly red line and Eclipse will present you with a list of options for correcting the error. Never write another import statement!
ctrl + shift + o- Organize imports. Add missing imports, remove unused imports, and alphabetize the entire list.
Code Navigation
ctrl + j- Incremental find. It’s like find as you type in Firefox. Use
ctrl + jandctrl + shift + jor just the arrow keys to cycle results (notF3). Hitescto exit incremental find mode. ctrl + l- Go to specific line. Know what line you need need? This is faster than scrolling.
ctrl + o- Quick Outline. Allows quick navigation to any method within the current file.
ctrl + oagain shows inherited members. ctrl + t- Quick Type Hierarchy. Allows quick navigation to all sub- and super-classes.
ctrl + shift + r- Open resource. Just start typing and Eclipse will present you with a list of matching resources.
ctrl + shift + t- This one actually isn’t working for me, but they tell me it’s pretty cool.
Editor
ctrl + e- Browse editor windows. Pulls up a list of all open editors for easy navigation.
ctrl + m- Maximize current window.
ctrl + shift + F4- Close all open editor windows. Great for cleaning up your workspace quickly so you can get a fresh start.
Refactoring
alt + shift + r- Rename local variable. Pick a new name and Eclipse will rename all instance of this variable.
Other non-keyboard-shortcut tips for getting started with Eclipse are here.
Plugins
Eclipse has plugins, too! Some that I use:
- Subclipse
- Subversion integration
- FindBugs
- “[U]ses static analysis to look for bugs in Java code”
- Checkstyle
- Checkstyle integration; “Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard”