Home > java > Eclipse tips and tricks – Part 3

Eclipse tips and tricks – Part 3

Here are a few more tips / tricks with which you can save time when you use the eclipse IDE.

Assign Key bindings:


Navigate to Window -> Preferences -> General -> Keys

You will find that there are many key bindings that are not assigned to actions that you might do on a daily basis. For example, when I start up on a new project, it is highly likely that I will introduce a lot of Value Objects (or Transfer / Data object, whatever you like to call them). A slick feature is to generate the ‘Getters and Setters’ for them using the ‘Source -> Generate getter and setter’ command from the Main menu.

You can either do that or you can assign a shortcut key to this action and get it done quickly. I use Alt+Shift+Q, +G (Yeah not the easiest combination. I know :) ). To restart eclipse I use Ctrl + F12. You might want to look at other bindings like

  • Generate hashCode
  • Generate toString()
  • New package
  • New class

And so on…

Reduce number of code suggestions:


The shortcut I use the most in eclipse is perhaps ctrl+space. Code completion is a real time saver. It can however be annoying when you press ctrl+space more than once by mistake. This by default, brings about suggestions for SWT templates among other things. You can turn this off by navigating to Window -> Preferences -> Java -> Edtior -> Code Assist.

Import preferences:



If you are like me, your hard disk probably has more than 100 eclipse Workspaces. Developers usually customize their workspaces and it can take a while to do this. When you switch to the new workspace, some of the customization is lost because they were workspace specific. You can get them back easily by exporting your preferences in the old workspace and importing them again in the new one. Use the File -> Export / Import option to do this. Preferences like code formatting, code templates, default compiler settings etc will be readily available.

Remember more workspaces: (Works on myeclipse)



Use this technique to allow eclipse to give you more drop down choices when you startup. By default eclipse remembers the last 5 workspaces used. You can increase / decrease this number by navigating to Window -> Preferences -> General -> Startup and Shutdown -> Workspaces.

Associate eclipse with an external browser like firefox :



Eclipse uses the system default browser. In most cases this is IE (gulp). You can change that by defining an external browser by navigating to Window -> Preferences -> General -> Web Browser.. This is great when you combine it with a plugin like Firebug. You get to code and debug HTML / CSS / Javascript all at once.

Work with local history:


Screwed up your java file and then saved it ? Yikes. Local history comes to your rescue. Every edit and save that you make in a file is saved as a local history in eclipse. Make use of this to revert changes when necessary.

To use this feature, right click on the file of your choice and click Compare With -> Local hisory. That should open up the entries in the ‘History’ view.

Clicking on any of the history entries will open a diff window telling you the difference between the current entry and the previous edits. Ah ! time is saved.

This is a 3 part article. If you would like to browse through the other tips, you can find them here

Eclipse tips and tricks – Part 1

Eclipse tips and tricks – Part 2





Categories: java Tags: , , ,
  1. June 16th, 2010 at 09:21 | #1

    Shift + Alt + S, r -> Generate Getters and Setters
    Shift + Alt + S, o -> Generate constructor using fields

    …etc…

    I tried to create a bug in bugzilla to create a shortcut to generate getters and setters and they introduced me to these :) )

  2. June 16th, 2010 at 12:30 | #2

    @Ignacio Coloma

    They are a tad long sometimes, but it sure beats reaching the mouse for the menu :D

  3. June 17th, 2010 at 11:13 | #3

    Nice article. The tip i was looking for

  1. No trackbacks yet.