Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "FAQ How do I create my own key-binding configuration?"

 
(Added introductory paragraph, updated to match Eclipse 3.4. However, I do not understand what file this keyConfiguration goes into, so this article is still incomplete.)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
On the '''Workbench > Keys''' preference page, you can choose the  
+
A keyboard shortcut (key binding) defines a key that when pressed will execute an Eclipse command.  Keyboard shortcuts are organized into independent sets called key configurations or schemes.  The user chooses the key configuration that emulates the shortcut keys of his or her favorite editor or IDE.
active key-binding configuration.  These configurations specify the keyboard
+
 
shortcuts to use for the various tools, actions, and editor features in Eclipse.
+
To see the current key configuration and its keyboard shortcuts, choose the '''Window > Preferences''' menu command to open the Eclipse workbench '''Preferences'''.  Select the '''General > Editor > Keys''' page.  This page displays the currently active '''Scheme''' (key configuration) and the keyboard shortcuts it defines'''Emacs''' is a set of keyboard shortcuts that emulates emacs. Similarly, '''Microsoft Visual Studio''' defines a set of shortcuts that emulates that IDEThe native configuration for Eclipse is '''Default'''.
By default, the platform includes a standard configuration and an
+
 
<tt>emacs</tt> configuration.  There are no APIs for defining  
+
There are no APIs for defining key-binding configurations programmatically, but you can create them in a plug-in by using the <tt>org.eclipse.ui.commands</tt> extension point.  First, you need to define your new configuration:
key-binding configurations programmatically, but you can  
+
create them in a plug-in by using the <tt>org.eclipse.ui.commands</tt>
+
extension point.  First, you need to define your configuration:
+
 
<pre>
 
<pre>
 
   &lt;keyConfiguration
 
   &lt;keyConfiguration
Line 16: Line 13:
 
</pre>
 
</pre>
  
By specifying a parent, you are saying that your configuration should inherit key
+
By specifying a parent, you are saying that your configuration should inherit key bindings from the parent unless they are explicitly set in your configuration.  When key bindings are defined, they will refer to the configuration they belong to.  If you write your own configuration, you&#146;ll also need to define new key bindings for all the commands that you want to belong to your configuration.
bindings from the parent unless they are explicitly set in your configuration.  When key
+
bindings are defined, they will refer to the configuration they belong to.  If you
+
write your own configuration, you&#146;ll also need to define new key bindings
+
for all the commands that you want to belong to your configuration.
+
 
+
  
 
== See Also: ==
 
== See Also: ==
 +
*[[FAQ How do I provide a keyboard shortcut for my action?]]
  
[[FAQ_How_do_I_provide_a_keyboard_shortcut_for_my_action%3F]]
+
{{Template:FAQ_Tagline}}
 
+
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
+

Latest revision as of 19:11, 17 December 2008

A keyboard shortcut (key binding) defines a key that when pressed will execute an Eclipse command. Keyboard shortcuts are organized into independent sets called key configurations or schemes. The user chooses the key configuration that emulates the shortcut keys of his or her favorite editor or IDE.

To see the current key configuration and its keyboard shortcuts, choose the Window > Preferences menu command to open the Eclipse workbench Preferences. Select the General > Editor > Keys page. This page displays the currently active Scheme (key configuration) and the keyboard shortcuts it defines. Emacs is a set of keyboard shortcuts that emulates emacs. Similarly, Microsoft Visual Studio defines a set of shortcuts that emulates that IDE. The native configuration for Eclipse is Default.

There are no APIs for defining key-binding configurations programmatically, but you can create them in a plug-in by using the org.eclipse.ui.commands extension point. First, you need to define your new configuration:

   <keyConfiguration
      name="My Configuration"
      parent="org.eclipse.ui.defaultAcceleratorConfiguration"
      description="This is a simple configuration"
      id="org.eclipse.faq.sampleConfiguration">
   </keyConfiguration>

By specifying a parent, you are saying that your configuration should inherit key bindings from the parent unless they are explicitly set in your configuration. When key bindings are defined, they will refer to the configuration they belong to. If you write your own configuration, you&#146;ll also need to define new key bindings for all the commands that you want to belong to your configuration.

See Also:


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.

Copyright © Eclipse Foundation, Inc. All Rights Reserved.