Tips and Tricks for Dealing with the Clunkiness of Eclipse

In the world of Java (or all purpose) IDE’s there are a few that stand out (to me at least):

  • IntelliJ
  • Netbeans
  • and, of course, Eclipse

I’ve mostly worked with Eclipse, but I’ve briefly tried the others. They all (arguably) have the same set of features, but Eclipse has one important feature that the others don’t: CLUNKINESS!

So, why do I use it? Well, once you get set up with it and used to it’s quirks it has all the features, it’s open source (so I should fix it instead of complaining) and it doesn’t seem worth the investment to start over with something else.

Anyway, I‘ve been bouncing back and forth between Java and JavaScript for the last few of years and my consternation with Eclipse increased a bit when I started using Sublime Text. The simplicity, the speed, the useful type ahead and most of all multiple cursors! Eclipse may never get there, but in the meantime, I’ve found a number of tricks and tweaks that I’d like to share to help you get bit closer. Let’s start with the cursors!

Multiple Cursors

Once you get used to the multiple cursors in Sublime Text 2/3 you can virtually generate code on the fly. Especially, when you use them with other keyboard shortcuts to skip words, move lines, etc. Eclipse just doesn’t have this and I’ll admit, sometimes I’ll go back and forth between the 2 to take advantage of that feature in Sublime. However, many people don’t know that Eclipse DOES offer multiple cursors! It’s just a far inferior version:

cmd + option + A
This will change your cursor so you can highlight multiple lines and edit them at once. It uses columns so you can’t do nearly as many things as you could in Sublime, but it still comes in handy on occasion. Hit the same cmd again to go back to the normal cursor.

Text editing

Eclipses keyboard bindings for copying/moving lines is (believe it or not) superior to that of Sublime’s. Here they are:

  • Copy up/down: cmd + option + arrow up/down
  • Move up/down: option + arrow up/down
  • Delete line: cmd + D (…much better than Sublimes ctrl + shift + k, which requires 2 hands!)

Smooth, simple and elegant to copy and then move a line up or down. Much better than selecting and doing a copy and paste.

Search

Searching in Eclipse is indexed and super fast and therein quite powerful!

One thing I don’t like though, is that it automatically opens the Java Search tab when you’re in a .java file, even though I used File Search on my last search. Java Search has some nice features, but I ended up dumping all tabs except File Search:

  1. ctrl + h to open the search modal
  2. Hit ‘customize’ in the lower left hand corner
  3. Delete any tabs you don’t need.

Having said this, another option might be to use cmd + shift + L for quick search. …been meaning to use it more myself. ;)

Code Assist

In Sublime, you get a dropdown as soon as you type a character. Eclipse has a different philosophy: pause to let you finish typing before giving you the dropdown. However, you can set it up to be more like Sublime if you prefer:

  1. Preferences > Java > Editor > Content Assist
  2. Set “Auto activation triggers for Java” to “.abcdefghijklmnopqrstuvwxyz” (no quotes). This will set auto completion to open automatically while typing.
  3. Lower milliseconds for code complete.

Tabbing after bracket completion:
It’s always annoying when your editor completes a bracket, curly brace, quote, parenthesis, etc and then you have to use the arrow key to go past it to add your semicolon. In Eclipse, you can just hit tab to go to the next part.

Importing Projects

This is easy, but not necessarily intuitive. If a project folder is copied your workspace folder it doesn’t show up in Eclipse until it’s added. To do so, you can import it from another location or create a new project using the same name as the directory it lives in. That’ll do the trick.

Standard, but useful, shortcuts

Organize imports: cmd + shift + O
Useful if you, like me, have a pet peeve about unused imports.

Source menu: cmd + option + S
This gives you access to code generation (getters/setters, etc) among other things. You’ll be using it often so stop right clicking!

Find in: cmd + option + W
Show a file in a number of different views including Package Explorer and Navigator (so you can know what dir it lives in and find it on the file system)

Open Call Hierarchy: ctrl + option + H

Quick Outline View: cmd + O

Themes

Eclipse’s default theme is designed to burn your eyes out! Luckily, Eclipse now comes (since Luna, I believe) with a dark theme, called (wait for it) “Dark Theme”.

Preferences > General > Appearance > Theme: Dark

You might need to restart Eclipse to get it working perfectly.

You can also create your own theme or install one someone else has put together. Some info here:
http://stackoverflow.com/questions/6937825/how-can-i-change-eclipse-theme
http://eclipsecolorthemes.org/

In Conclusion

Hope this helps and that I didn’t offend anyone with any of my opinions!!! Either way, feel free to comment with refutals, other tips and tricks or anything you feel is relevant!