My Top 10 Tips on how to be more productive with the Eclipse IDE

My Top 10 Tips on how to be more productive with the Eclipse IDE

Eclipse ProductivityI’ve met many programmers over the years who had just started using Eclipse or already had “some experience” — but they used Eclipse just as a text editor or handled it in a very cumbersome way. The main problem was that they hadn’t yet learned about Eclipse’s capabilities and how to leverage its powerful features.

So, I thought I would write about my top 10 recommendations that will make your programming life easier and make you more productive.

Note: Click on the images to reveal a larger screenshot.

1. Text File Encoding

Text File Encoding Preference
The default setting for saving files in your Eclipse workspace is to use the file encoding of the underlying operating system. However, you usually want to create a platform independent application. To accomodate this,  set the file encoding to UTF-8. Using UTF-8 will prevent problems with special characters if you deploy to a system that runs a different OS, run your build on a UNIX machine or if somebody else works on the code using a different OS. You’ll find the settings in: Preferences > General > Workspace or in your project specific settings.

2. Save automatically before build

Save automatically before build
One thing I noticed is that people (including me) are constantly hitting Ctrl+S to save or even worse — grabbing the mouse to hit the Save action in the toolbar. This behavior seems to originate from experiences where an application was started from the workspace without saving and of course, changes were then lost. You can save some keystrokes and mouse clicks by enabling Save automatically before build.  This is in: Preferences > General > Workspace

3. Type Filters (for PDE / RCP developers)

Type Filters
Type Filters remove suggestions for certain types (e.g. classes, interfaces) from the “Open Type” dialog, content assist and quick fix proposals. Especially as an RCP / SWT developer you most likely don’t want suggestions for Swing components like Button, Label, etc.

You’ll find this setting in: Preferences > Java > Appearance > Type Filters

4. Use “Step Filtering” for Debugging

Step Filtering
With “Step Filters” you can filter out types that you do not wish to see, or step through while debugging. This helps you to stay focused on the actual code and does not expose you to the inner workings where you might not even have the source. Have a look at Holger’s Effective Mockito post about Step Filtering in conjunction with Mockito.

You’ll find this in: Preferences > Java > Debug > Step Filtering

5. Always launch the previously launched application

Always launch previously launched application
This option will ensure your last launched configuration is used. In the default setting, Eclipse tries to determine the most appropriate configuration for the currently selected resource — which can be quite annoying. Set this under: Preferences > Run/Debug > Launching

If you want to automatically stop running instances when you start a new one, have a look at Launch an OSGi app and automatically kill its running instance.

6. Store your Launch Configuration in a Project

Store your Launch Configuration in a Project
You probably spend a good amount of time crafting your launch configuration. You can actually store it as a file in one of your projects so you can check it in. This way you can share it with colleagues and save them from reinventing the wheel.

You’ll find this Preference in: Menu: Run > Run Configurations… > Launch Configuration Tab: Common

Hint: You can access the Launch Configurations dialog by clicking the Launch/Debug action in the Toolbar while holding the ctrl key or cmd on a Mac.

7. Make a Launch Configuration always appear in the Menu

Make a Launch Configuration always appear in the Menu
If you have multiple Launch Configurations, you can choose your favorite ones and stick them permanently to your Launch/Debug menu.

Go to: Menu: Run > Run Configurations… > Launch Configuration Tab: Common

8. Organize imports on save

Organize imports on save
Java developers really don’t need to worry about imports in Eclipse. The imports are automatically added to the class file. But, changing or removing code might make some imports obsolete. To fix that, you can Organize Imports by hitting shift+crtl+o or shift+cmd+o on a Mac and your imports will be cleaned up. Or you can enable Organize imports on save and Eclipse will take care of that automatically.
You’ll find this in: Preferences > Java > Editor > Save Actions or in your project specific settings.

9. Format edited lines on save

Format edited lines on save
The code formatter in Eclipse is a very useful thing. It ensures that the code looks consistent in your projects — no matter who wrote it — and can be easily read and understood by anyone else. But, formatting the whole file can seriously mess up a diff between two versions of the file. So ‘format only edited lines on save’ might be the right choice if you want the have your code formatted and still be able to see what was changed in your code later on.

You’ll find this in: Preferences > Java > Editor > Save Actions or in your project specific settings.

You might also want to take a look at the Eclipse Checkstyle Plug-In. This will help you to enforce your coding guidelines.

10. Let Eclipse do the typing

A good IDE should support the developer in writing his code at nearly the speed of thought. And Eclipse comes quite close to this with Refactorings, Quick Fixes, Code Assist/Code completion and more. So don’t type too much yourself — you will, here and there, type something wrong, overlook something, scroll through code, which costs a lot of time. Force yourself to use shortcuts!

Here is an example. If you want to store a method parameter in a field, just set the cursor on the parameter name, hit the Quick Fix shortcut and select Assign parameter to new field. And poof, you’re done. If you need a getter, type get somewhere in your class (outside of a method declaration) and use Content Assist to let Eclipse create the method for you. The same applies for creating setters, the main method, the constructor and more.

    • Quick Fix: ctrl+1 or cmd+1 on a Mac
    • Content Assist: ctrl+space (for Mac and PC)
    • Quick Access: ctrl+3 or cmd+3 on a Mac

aka ctrl+awesome

  • Open Type: shift+ctrl+T or shift+cmd+T on a Mac

Use the Mousefeed Plug-In, to learn keyboard shortcuts.  It gives you a message showing the keyboard shortcut for the action you just performed with the mouse.

11. (Bonus Tip) Get a Solid-State Drive

Eclipse has to handle many small files: source code, compiled files, metadata, local history, git, etc.  And, the hard drive you use has a massive impact on most of the actions you perform throughout the day. A major performance boost , and therefore a productivity boost, can be achieved by upgrading to an SSD. Here is an article from Dr. Dobb’s on that topic.

If you have feedback or something to add, please feel free to leave a comment below.