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

eclipseSpeed 150x150 My Top 10 Tips on how to be more productive with the Eclipse IDEI’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

1s My Top 10 Tips on how to be more productive with the Eclipse IDE
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

2s My Top 10 Tips on how to be more productive with the Eclipse IDE
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)

3s My Top 10 Tips on how to be more productive with the Eclipse IDE
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

stepfilters s My Top 10 Tips on how to be more productive with the Eclipse IDE
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

5s My Top 10 Tips on how to be more productive with the Eclipse IDE
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

6s My Top 10 Tips on how to be more productive with the Eclipse IDE
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

7s My Top 10 Tips on how to be more productive with the Eclipse IDE
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

8s My Top 10 Tips on how to be more productive with the Eclipse IDE
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

9s My Top 10 Tips on how to be more productive with the Eclipse IDE
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.

You may also like...

Share this Post

Twitter0
Google+105
LinkedIn
Facebook

Tags

5 Responses to “My Top 10 Tips on how to be more productive with the Eclipse IDE”

  1. Mário Marinato says:

    Thanks for this post, man. I use most of those tricks but gotta check out numbers 3 and 4.

    I like to use the SaveMe plugin, which saves text files when its editor loses focus. It’s available from here: http://www.stateofflow.com/UpdateSite

    Another thing I do is setting a number of actions to be taken upon file saving:
    Remove unused imports, add missing @Override annotations, remove unnecessary casts, remove unnecessary $NON-NLS$ tags, and remove trailing white spaces on all lines.

    It keeps source files sane. Those can be set on Preferences – Java – Editor – Save Action.

    Regards from Brazil

  2. Sven Efftinge says:

    Good collection! I think this could be a great topic for an EclipseCon talk.
    Early bird submission deadline is Wednesday :-)

  3. maureyeslopez says:

    Great tips! Even that simple tips to Organize Imports or Refactor the modified code after save are very useful.

    I’ll try the rest.

    Thanks.

  4. Christian says:

    My past experinces about number 1 were that it ist not enought to change the encoding to UTF-8 only at this one place. There are a lot of more encoding settings under Preferences/General/Content Types. Also you can find more encoding settings under Preferences/Web/CSS Files, Preferences/XML… and so on. What about these settings??

    Thanks.

  5. Jeremy says:

    A must follow list! Thanks!!

    Rule #1 and #10 are my favorite!

    I save a lot of time also using the snip2code plugin
    (http://marketplace.eclipse.org/node/478177#.UJrLgG8mY6c)

    I use it for my code snippets, allows me to search and easily collect them. Really quick programming.

    Thanks
    J.

5 responses so far

Written by . Published in Categories: Planet Eclipse

Published:
Oct 26th, 2012
Follow:

Twitter LinkedIn Google+ GitHub