Setting up Eclipse: Ganymede Edition
July 6th, 2008 — Articles, IDE, Productivity
It’s that time of the year again… The Eclipse community makes us regular schmucks look like slobs by not only delivering a single project feature-complete and on time, but twenty three (Hopefully my project manager doesn’t ever hear about this!). Overall I am very impressed with the Ganymede release. I really like the breadcrumb navigator in the Java Editor and everything seems more polished and stable than in my old Europa install. The only problem I had was with the Subversive svn plugin. I understand that they were having licensing issues with Polarion (the company behind subversive), but if that is the case, they shouldn’t have shipped it as part of Ganymede at all. For those of you whom haven’t tried this out yet, there are two plugins you need to get subversion support in Eclipse, the Subversive Plugin and the SVN Connectors. You can’t get the Connectors plugin directly from Eclipse though, which makes the Subversive Plugin bomb out when you try to connect to a repository (but appear to work fine otherwise). To get a working svn client in Eclipse you will need to add the Polarion update sites for the client and connectors to your update manager [http://www.polarion.org/index.php?page=download&project=subversive].
I’ve spent a bit of time this weekend setting up Eclipse to behave the way I like. The following is what I generally do to a new Eclipse installation… feel free to leave any customization tips you may have in the comments
Key Bindings
The first thing I always do is switch the key-binding settings over to Emacs mode (General -> Keys -> Scheme: Emacs). Even if you don’t use Emacs, you should use these key-bindings. The main benefit you’ll get is in-file navigation (Ctrl+P, Ctrl+N, Ctrl+F, Ctrl+B for moving up, down, right, and left respectively). Not only that, but you will also be able to perform in-file searches as well (Ctrl+S and Ctrl+R for incremental and reverse-incremental). Many of your java-specific key-bindings remain the same such as Ctrl+Shift+O for organizing imports and Ctrl+Shift+T for opening class files. The only weird part is the keys for code suggestions changed from Ctrl+Space to Alt+/. It is well worth it to learn these keys and make the switch. You will spend little in effort for lots of gain in productivity.
Code Formatters
This is still a problem in Ganymede… I hate that I have to specify my tab policy in each formatter instead of having a set of global formatters for everything. I like having spaces vs tabs in my source code. Yet still I have to create a separate new profile for Java, JavaScript, CSS, HTML, XML, Ant, etc… It would be nice to have one place to say: I want to use spaces only, restrict code to 80 chars wide, put else blocks on a new line, etc… To change this, it is easiest to do a search in the Preferences menu for “format” and then setup each individual formatter/editor to your liking.
Save Actions
One of my personal favorite things about Eclipse is Save Actions. You can set your Java Editor up so that it performs a list of actions whenever you save a file. For example, I have my editor setup to format the source code, add the ‘this’ qualifier to field accesses, organize imports, remove unused imports, add @Override and @Deprecated annotations, and to remove trailing whitespace. This saves me lots of time and helps me write code the way I truly want to (instead of allowing me to be lazy). Once of the cool features of Ganymede is that you now have the option to only format edited lines. This is helpful when you are working on code from CVS or Subversion and somebody else may not have formatted their code like yours.
Code Templates
Under Java -> Code Style -> Code Templates you can setup how you want your comments and code laid out for you. For example, you can put a standard licensing message at the top of every new file or stamp each type with the date and time it was created. Very handy stuff and almost anything is better than the defaults, so make sure you go through here and set these up how you like them.
Then it is off to work. Happy Hacking!





