Useful Eclipse keyboard shortcuts for Java development

Since I've started developing Java in Eclipse I have realized that this is in no way different than with most other IDEs: the speed of development highly depends on the knowledge and intuitive usage of keyboard shortcuts.

Occassionally I'm asked to slow down a bit so that one can follow my actions or to tell which shortcut I've just used. For this reason I'm making this small list of those shortcuts which I'm using pretty much all the time.

I've tested these shortcuts specifically on Eclipse Galileo (3.5.1) and on Windows but most of them are also already present on earlier versions of Eclipse. As for other platforms I don't really know if all of them (or even any one of it) are available (or at the same combination). Furthermore many of them should also be present when developing different programming languages than Java but I cannot confirm that. You just have to find out yourself. Just in case you do, please let me know in the comments :)

So without further ado:

Shortcut Function Description
CTRL+SHIFT+ROpen Resourcebrings up a dialog where you can quickly locate any file or resource in your workspace. Wildcards are supported in the search.
CTRL+SHIFT+OOrganize Importscleans up the imports-block at the beginning of the file. Adds missing imports (if neccessary) and removes unused ones.
CTRL+SHIFT+FFormatapplies proper formatting to the source code according to the style-settings in the *Java->Code Style->Formatter* preferences.
ALT+UP/DOWNShiftmoves the current line or selection up or down one line. Very useful for fast relocation of code, much faster than cut/paste if just moving a few lines.
CTRL+ALT+UP/DOWNDuplicateduplicates the current line or selection above or below the current line/selection. Allows the fast population of cases in switch/case statements if they differ just marginally or similar situations like variable-initializer blocks. Beware, that this shortcut is often also overridden by some Intel display drivers. If this one does not work for you, try to turn off or change the hotkey assignment in your display driver helper application.
CTRL+OQuick Outlnebrings up a small dialog which allows to search and navigate the outline of the current file. Just start typing to narrow down the results. Supports wildcards. Pressing CTRL-O again toggles the display of inherited methods.
CTRL+PGUP/PGDOWNSwitch Tabchanges to the next/previous editor-tab.
ALT+SHIFT+LExtract Local VariableCreates a local variable from the currently selected expression. Types are automatically added. Try it on the code 'new HashMap();' to understand how this can speed up your development. Works on variables, static strings, methods with return values, etc.
ALT+SHIFT+IInline Variableopposite of local variable extractions. Replaces all occurences of the currently selected variable with its assigned value. Only works if the value of the variable is set exactly once.
CTRL+ALT+HCall Hirarchyshows all calls/usages of the currently highligted variable/interface/class/method.
F3Open DeclarationJumps to the declaration of the currently highlighted variable/interface/class/method. Similar to holding down CTRL and clicking with the mouse on a variable/interface/class/method.
CTRL+SHIFT+LShow Key AssistDisplays a popup which displays currently assigned keyboard shortcuts. Very useful if you are looking for further shortcuts quickly. A shortcut for shortcuts ;)

There are many more shortcuts available, including the marking and navigation shortcuts which you should know from Microsoft Word, but the above ones are the ones which became ingrained in me and are now speeding up my Java development enormously. Try to get used to them and use them whenever you can and you'll realize that there will be fewer and shorter interruptions to your stream of thought and it also aids your concentration.

If you want to go a tad further and let Eclipse tell you about possible shortcuts (or even force you to use one by cancelling all mouse-events which have a shortcut) you can install the MouseFeed Eclipse Plugin which does exactly this by displaying a small shortcut reminder each time you issue a shortcutted command with the mouse. Although it's a plugin for Eclipse 3.3, it still works with Galileo.


Similar entries


here is my list of useful eclipse shortcut I would rather say very useful and practical eclipse shortcut :)

Javin Paul
FIX Protocol tutorial