Bastian's Blog

Bastian's Blog

Info | HTML | Text | RSS

On short notice: Keybindings in Eclipse PDT

There was a discussion started by Nils Langer ( earlier this morning about most often used keybindings in the IDE Eclipse PDT. As I did not want to flood his commtents section with a huge comment I wrote this answer.

Switching uppercase to lowercase and vice versa

The coding standards of my employer says that constants have to be written in uppercase letters. But until I find it very uncomfortable to hold down the SHIFT key for the whole word nor am able to find the CAPS LOCK key in time, I always write the name of a constant in lowercase letters and use the following sequence to convert it afterwards:

SHIFT + Alt + left arrow (select previous word) CTRL + SHIFT + x (uppercase the selection)

For those capable of the ten fingers system it might be too pedestrian, but I an not a ten finger writer I find it right useful. By the way CTRL + SHIFT + y convert the selection to lowercase.

Repeatingly running an External Tool Configuration

As I am following the test first paradigm when writing source code. I use the External Tools Framework of Eclipse to run PHPUnit to see if my tests are good to go. The drawback on this is that you always have to use the mouse to klick the little icon in the menubar running the latest launched external tool. Last week I finally found a solution for this. There is a predefined action "hidden" in the configuration section (Window > Preferences > General > Keys ) for keybindings in Eclipse named "Run last launched External Tool" which is exactly the event triggered when you hit the run button in the menubar to rerun the e.g. unit tests on the currently active file again. I bound it to SHIFT + CMD + r (yes I am currently using Mac) which freed me from using the mouse a lot of times a day.

Editing multiple lines at once

Another more or less unknown keybinding is Alt + CMD + a. Vim user might know this imho very nice feature already and as a former Vim user I missed it very badly in Eclipse. Once this keybinding is enabled the mouse pointer changes into a target pointer. If you now select a multiline section with your mouse the selection will not cover the whole lines as usual, but only the section you chose. If you now start typing each line will geht the same content as what you entered. Since the keybinding toggles the blockedit mode you just it it again and you are back in the normal edit mode.


Since this article only represents a small set of my daily used shortcuts the need for a cheatsheet or a conclusive overview over every keybinding would be very nice. As a matter of fact there a re two of those overview. The first and system specific one you find if you hit SHIFT + CMD (CTRL on windows) + l which causes a popup to appear in the lower right corner of your workspace. The other more general one is a cheatsheet created by Carsten Ullrich available on sourceforge. This cheatsheet afaik does not cover all available shortcuts, but do give you a good overview on common used keybindings.

If you like this article, I'd be very pleased if you'd flattr me.



Add new comment

Fields with bold names are mandatory.