Wednesday, December 20, 2006

Assigning Keys to Commands in Subclipse

The Subclipse 1.1.x releases have a new feature that allows you to assign keyboard combinations to various Subclipse commands, such as commit and update. This is an often requested feature by keyboard aficionados. The feature is built on top of the standard mechanism provided in Eclipse for assigning key combinations to commands, so if you are familiar with how that is implemented, that is probably all you need to know to get started. For the rest of us, here is how you assign a key combination to a command.

First, open the Eclipse Preferences using Windows -> Preferences. Then expand the General section of the preferences and click on the Keys preference item. You could also just type Keys in the preference filter on the top of the dialog. You should see a dialog something like this, although in this case the data has already been filled in:



In the category drop-down, you will want to select "SVN". In the Name drop-down, you can then select the SVN command you want to assign a keyboard combination to. You then tab down to the Key Sequence name field. This is where you are going to assign the keyboard combination. To do so, just type the combination you want to use. For example, in the screen shot, I have used Ctrl-Shift-C. The assignments list will show you any existing commands that have been assigned to that combination, as well as the context in which they apply. The final step is to select the context in which you want this combination to be active. The most likely candidate is "In Windows". Once you are done click the Add button and you are done. You can assign more combinations if you want, when you are done just click the OK button to close the preference dialog.

Once the combination has been assigned, you should now see that combination in the Eclipse team menu, or any other place the command you selected appears.



There have been several links to the Eclipse documentation placed within this post. I'd encourage you to read the Eclipse documentation for more information on using this feature.

3 comments:

Paul said...

That is sure to be a useful feature. I for one make extensive use of keyboard shortcuts in just about every application I use ... that is why it is taking me so long to be proficient with the keyboard on the Mac - there are so many damn keyboard shortcuts!!

It was really interesting to read through the dialog between yourself and Denny Valliant up at subclipse.tigris.org; it really is amazing to see just how much work goes into a feature that is, at face value, so simple and taken for granted!

Nice work guys ...

Anonymous said...

In the Eclipse 3.3, the layout of the Keys preference page has changed.

Make sure you uncheck the Include unbound commands, otherwise you won't see the SVN commands.

- Fernand.

Shonzilla said...

Plugin commands which can be invoked using keyboard are also exposed as corresponding binding extension points within plugin's plugin.xml.

Does anyone know if all available/possible (i.e. implemented) keyboard bindable commands are declared in plugin.xml by default? Or the other way around, I'd like to know if it's possible to add new bindable commands to a given plugin (and consequently bind them to keyboard shortcuts) without coding the corresponding command handler in Java?

Cheers!
Shonzilla