Key and Mouse Bindings

Key and mouse bindings are quick ways to execute operations in SlickEdit® Core. Key bindings are the most efficient. Time is wasted each time you lift your hand from the keyboard to grab the mouse, and more time is wasted when you move your hand back to the keyboard in preparation for more typing. Therefore, if you learn the key bindings associated with operations that you use most frequently, you will save time coding. If an operation you use frequently isn't already bound by default, create your own easy-to-remember binding.

What is a Binding?

A key or mouse binding is a key sequence or mouse event associated with a command. Key terms are defined as follows:

  • Mouse event - The clicking of any button or motion of the mouse wheel.

  • Key - Any single key on the keyboard.

  • Key combination - Two or more keys pressed simultaneously, for example, Ctrl+O (in CUA emulation, associated with the gui_open command, File → Open, and the Open button on the Standard toolbar). The plus (+) sign between the keys indicates that these keys must be pressed simultaneously: press the Ctrl and O keys at the same time. Note that the last key is case-insensitive. You do not need to press Shift.

  • Key sequence - A series of one or more keys or key combinations, for example, Ctrl+X,R (in Vim emulation, this binding is associated with the redo command, Edit → Redo, and the Redo button on the Standard toolbar). The comma (,) indicates that each key must be pressed consecutively: press Ctrl and X at the same time, release, then press the R key.

  • Key binding range - A command bound to a range of keys. For example, the alt_bookmark command is bound by default to the key combination range of Ctrl+0 through Ctrl+9. Press Ctrl+0 to create a bookmark named "0", Ctrl+1 to create a bookmark named "1", etc.

To view or change bindings, create new bindings, and export/import custom bindings, see Key and Mouse Bindings.

The available key bindings change depending on the selected emulation. While SlickEdit® Core provides emulations for 13 editors, CUA is the default emulation, so key bindings listed throughout the documentation are for the CUA emulation. To change the emulation mode, click Window → SlickEdit Preferences → Keyboard → Emulation. For more information, see Emulations.

Note

  • For documentation purposes, both mouse events and keys that are bound to commands are often referred to collectively as key bindings.

  • The SlickEdit Core main menu displays the key bindings for commands associated with each menu entry. See Menus and Creating and Editing Menus for more information.

  • A menu hotkey is a key sequence that corresponds to an underlined letter on a menu name.

Managing Bindings

Create and manage key bindings using the Key Bindings option screen. This displays a list of all SlickEdit® Core commands, including macros that you have recorded, their associated key sequences, and the language editing mode in which the key binding can be used. Documentation for the selected command, if available, is also displayed. The Key Bindings screen provides capabilities to incrementally search by command or by key sequence, export and import custom bindings, save an HTML chart of your bindings, and run a selected command or user-recorded macro.

To access the Key Bindings option screen, from the main menu, click Window → SlickEdit Preferences → Keyboard → Key Bindings, or use the gui_keybindings command.

The first time the Key Bindings screen is invoked, the Building Tag File progress bar may be displayed while Slick-C® macro code is tagged.

Bindings are based on the editor emulation mode (CUA is the default). To change the emulation mode, click Window → SlickEdit Preferences → Keyboard → Emulation. For more information, see Emulations.

The Search by commandand Search by key sequence boxes are used to filter the data. See Viewing and Filtering Bindings.

The Command column shows all of the SlickEdit Core commands including macros that you have recorded. The Key Sequence column shows the key sequence or mouse event to which the command/macro is bound. If there is no binding, this field is empty. The Mode column shows the language editing mode to which the binding is assigned. The Recorded column indicates if the item is a command (No) or user-recorded macro (Yes).

Tip

TIP What is a language editing mode? SlickEdit Core uses the extension of the current file to determine what language you are using, thereby only making available the options and features that are possible or useful in that language. You can also manually set the language editing mode. See Language Editing Mode for more information.

The bottom of the screen contains documentation (if available) for the selected command.

Columns can be sorted by clicking on the column headers. An up or down arrow in the column header indicates ascending or descending sort order. All of the columns as well as the documentation pane can be resized by dragging the separator bars.

The following sections describe different ways to use the Key Bindings option screen:

Viewing and Filtering Bindings

You can filter the data on the Key Bindings screen by using the Search by command and Search by key sequence boxes at the top. This is useful for finding a command/macro for creating, editing, or removing a binding, and for determining what key sequences are associated with a command/macro and vice-versa.

  • To find a command/macro, search for it by entering a string in the Search by command box. The column of commands is filtered incrementally as you type, to show only commands that contain the specified string. Commands that have more than one key sequence associated with them are listed on separate rows. For example, in CUA emulation, the command gui_open is bound to F7, Command+O (on the Mac), and Ctrl+O. Therefore, gui_open appears in the Command column three times, one row per key sequence.

  • To find a key sequence, place the focus in the Search by key sequence box (by tabbing or using the mouse) and then press the actual key or key sequence. The column of key sequences is filtered to show only bound sequences that contain the specified key(s). For example, to see all commands/macros that are bound to Ctrl+O, with the focus in the search box, simply press Ctrl+O.

  • To find a mouse event, place the focus in the Search by key sequence box (by tabbing or using the mouse) and click the mouse event you want to find. If the mouse event involves the scroll wheel, click the Mouse Event button () to the right of the field. This displays the Select Mouse Event dialog containing a list of all mouse events. If the event involves pressing a modifier key or keys, such as Ctrl, Alt, Shift, Cmd, Ctrl+Alt, etc., in conjunction with a mouse click, for example, Ctrl+RButtonDn, press the modifier key(s) when clicking the Mouse Event button. Then the Select Mouse Event dialog shows a list of modifier-prefixed mouse events. After selecting the mouse event you want to look up, click OK. The option screen updates to show only those commands that are bound to that mouse event.

To clear either field, click the red X button to the right of each box. This is especially handy for the key sequence search, due to the fact that the field recognizes any keyboard/mouse input including Backspace.

Alternatively, you can use the what_is and where_is commands (Help → What Is Key and Help → Where Is Command) on the SlickEdit® Core command line to determine binding associations. See Using the Command Line to View Key Binding Associations for more information.

Creating Bindings

You can work more efficiently if you create key/mouse bindings for commands or user-recorded macros that you use frequently. To create a new key or mouse binding:

  1. Using the Key Bindings options screen (Window → SlickEdit Preferences → Keyboard → Key Bindings), find the command or user macro you want to bind. You can search for a command/macro by entering a string in the Search by command box (see Viewing and Filtering Bindings).

  2. Initiate the binding by using one of the following methods:

    • Select the row, then click the Add button.

    • Select the row, then press Enter.

    • Double-click on the row.

  3. When you initiate a binding, the Bind Key dialog is displayed with focus in the Key Sequence box.

    • For a key binding, press the key sequence just as you would to use it. For example, to bind surround_with to Ctrl+W, simply press Ctrl+W. The key sequence you pressed is displayed in the box.

    • For a mouse binding, click the Mouse button next to the Key Sequence field, and select the mouse event you want to use from the Select Mouse Event dialog. For example, to bind surround_with to the right-click mouse event, select RButtonDn and click OK.

    Use the red X button to clear the input field if you make a mistake. If you enter a key sequence or mouse event that is already assigned to another command/macro, a warning prompt is displayed. If you continue, the previous binding is unbound and reassigned.

    Tip

    • SlickEdit® Core allows key sequences that are very long, but shorter sequences are easier to remember and more practical to use.

    • Do not begin key sequences with keys that are normally used in typing. Otherwise, these keys will launch the operation and not appear when you type. For example, binding a command to the A key will prevent you from using that letter in your code. It is best to always begin your key sequences with a Ctrl or Alt key combination.

  4. The default language editing mode is the default language editing mode for new bindings, which means the binding will work in all language editing modes. If you want the binding to work only in a specific language editing mode, you can change it now by clicking the Advanced button on the Bind Key dialog. Click Bind to mode, then from the drop-down list, select the mode for which the binding should apply. Bindings assigned to a specific language editing mode override those assigned to default.

    Tip

    You can create multiple bindings for the same command/macro and have one binding set to default and the others set to specific modes. In this case, when you are editing in a specified mode, that binding is in effect, and when editing in any other language editing mode not specified, the default binding will be in effect. For example, in CUA emulation, Ctrl+L is bound to select_line by default, but when in HTML mode, you may want to use Ctrl+L to insert an HTML link instead (insert_html_link command). Therefore, you can bind Ctrl+L to insert_html_link and specify the HTML mode for use only when editing HTML files.

  5. When finished, click Bind. The key sequence or mouse event now appears in the Key Sequence column.

Editing Bindings

To change the binding or language editing mode for a command/macro that is already bound, you will need to first unbind the command/macro, then recreate it. See Removing Bindings and Creating Bindings. If you have advanced knowledge of SlickEdit® Core, you can edit the Slick-C® key binding source directly. See Editing the Key Binding Source for more information.

Removing Bindings

To remove a binding:

  1. Using the Key Bindings options screen, find the command/user macro or key sequence that you want to unbind. You can search by using the search boxes at the top (see Viewing and Filtering Bindings).

  2. With the command/macro row selected, click Remove, or press Delete. You are prompted to confirm the unbind operation.

If a command is bound to a range (see Working with Key Binding Ranges), for example, Ctrl+0 through Ctrl+9, the entire range is unbound.

Exporting and Importing Bindings

Key and mouse bindings can be exported out of SlickEdit® Core and imported in, useful for creating backups, sharing with other team members, or taking with you should you switch computers.

Exporting Bindings

When exporting, custom bindings for all language editing modes in the current emulation are exported into an XML file with a name and location that you can specify.

To export your bindings:

  1. Click the Export button on the Key Bindings option screen. The Save As dialog is displayed.

  2. If you want, change the directory location and change the file name to something more meaningful to you, such as myname_cua.xml.

  3. Click Save.

Importing Bindings

Imported bindings override any existing bindings for the selected emulation. For example, if you have the surround_with command bound to Ctrl+W, and import surround_with bound to Ctrl+Q, then Ctrl+Q is now the binding for that command in the selected emulation. When you import for the selected emulation, SlickEdit® Core resets the key bindings to the default, then loads the user key bindings.

If you import a key bindings file from a different emulation than the one currently selected, SlickEdit Core displays a warning and prompts whether or not you want to continue. If you continue, the emulation mode is changed and the key bindings are loaded for that emulation.

To import bindings into SlickEdit Core:

  1. Click the Import button on the Key Bindings option screen. The Open dialog is displayed.

  2. Find and select a bindings file that was previously exported, then click Open.

Saving a Bindings Chart

Click the Save Chart button on the Key Bindings option screen to save an HTML reference chart of all current bindings for all language editing modes in the selected emulation. Commands and user macros that are not bound are not included.

Running a Command/Macro using the Key Bindings Dialog

If you have the Key Bindings option screen open, you can conveniently run a selected command or user-recorded macro by clicking the Run button.

Resetting Default Bindings

To reset bindings for the selected emulation to the SlickEdit® Core defaults, from the main menu, click Window → SlickEdit Preferences → Keyboard → Emulation, then select the Restore to default key bindings option on the Emulation options screen. See Emulations for more information.

Working with Key Binding Ranges

A key binding range is a command that is bound to a range of keys. For example, the alt_bookmark command is bound by default in CUA emulation to the key combination range of Ctrl+0 through Ctrl+9. Press Ctrl+0 to create a bookmark named "0", Ctrl+1 to create a bookmark named "1", etc. Key binding ranges are displayed in the Key Sequence column on the Key Bindings option screen. For example, the range for alt_bookmark is displayed as Ctrl+0 -> Ctrl+9 in CUA emulation. Key binding ranges are also shown when using the Export and Save Chart features.

You cannot remove a single key combination from within a range, but you can rebind the key range to a different command. If you unbind a command that is bound to a range, the entire range is unbound.

Key Binding Settings

The following are settings that you can make pertaining to key bindings.

Key Message Delay

For key bindings that contain multiple key combinations, like Ctrl+X,Ctrl+C, you can specify the maximum delay between the two combinations. If that time limit is exceeded, this key sequence will be interpreted as two separate bindings, executing the command bound to Ctrl+X followed by the command bound to Ctrl+C, rather than the command bound to Ctrl+X,Ctrl+C.

To change this option, click Window → SlickEdit Preferences → Keyboard → Advanced, then set the Key message delay for the amount, in tenths of a second, to delay before a prefix key. The prefix key is not displayed if the next key is pressed before the delay specified in this text box.

Using Shorter Key Names in Menus

The SlickEdit® Core main menu displays the key bindings for commands associated with each menu entry. These bindings can be condensed for non-CUA emulations. See Menus for more information.