Sites
Projects
Written by Michael Zoech - 2008-09-17 01:30 - Comments - Tags: java, eclipse
There is an excellent post about Eclipse navigation shortcuts at 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know. Since this post only looks at navigation shortcuts, i thought i post some of my favourite Eclipse shortcuts i use every time in Eclipse to boost my productivity.
Use Ctrl + . or Ctrl + , to cycle through the errors in the current file. This marks the next or previous error. Hitting F2 shows the error description and the quick-fix menu. This is much faster than using the mouse to locate the error, float over and wait for the description to pop up. Note, this works for warnings too.

Hitting Shift + Alt X T runs the jUnit tests found in the current file. Use Shift + Alt D T if you want to debug-run the tests.
I often find myself in the need to run the same jUnit tests again and again. The jUnit plugin provides the ReRun Test button, i think i've hit a million times now.

Luckily you can create a shortcut binding for this. Go to Window -> Preferences -> General -> Editors -> Keys and setup an appropriate binding. I've bound this command to Ctrl + Alt R R. This makes it really easy to write tests, jump back and forth to the production code and rerun the same test files over and over again.
Surrounding already existing code with something like a try-catch block or a for loop is often tedious and error-prone. Not any longer. Mark the code you want to move inside the block or loop, hit Shift + Alt Z and select the type of surrounding block.
Before

After

Hitting Shift + Alt + R lets you rename a variable, method or class name at the current cursor position. The renaming happens not only in the current file, but takes care of all references to the variable, method or class in other files of the project.

Note that the renaming fixes the reference in the other method.
Shift + Ctrl + L shows a list of all shortcuts. Although i do not use this on a daily basis you may find even more interesting shortcuts there.
