Key BindingsВ. Key bindings are stored in files and defined in JSON. Keymap files may be located anywhere in a package. Naming Keymap FilesВ. Any keymap named will always be applied in all platforms. Additionally, each platform can optionally have its own keymap. Sublime Text will ignore any file whose name doesn t follow the patterns just described. Structure of a Key BindingВ. Keymaps are arrays of key bindings. These are all valid elements in a key binding. keys An array of case-sensitive keys. Modifiers can be specified with the + sign. You can build chords by adding elements to the array (for example, [ ctrl+k , ctrl+j ] ). Ambiguous chords are resolved with a timeout. command Name of the command to be executed. args Dictionary of arguments to be passed to command. Keys must be names of parameters to command. context Array of conditions that determine a particular context . All conditions must evaluate to true for the context to be active. See Structure of a Context below for more information. Here s an example. Structure of a ContextВ. key Name of the context whose value you want to query. operator Type of test to perform against key s value. Defaults to equal. operand The result returned by key is tested against this value. match_all Requires the test to succeed for all selections. Defaults to false. Context OperandsВ. auto_complete_visible Returns true if the autocomplete list is visible. has_next_field Returns true if a next snippet field is available. has_prev_field Returns true if a previous snippet field is available. num_selections Returns the number of selections. overlay_visible Returns true if any overlay is visible. panel_visible Returns true if any panel is visible. following_text Restricts the test to the text following the caret. preceding_text Restricts the test to the text preceding the caret. selection_empty Returns true if the selection is an empty region. setting.x Returns the value of the x setting. x` can be any string. text Restricts the test to the selected text. selector Returns the name of the current scope. panel_has_focus Returns true if a panel has input focus. panel Returns true if the panel given as operand is visible. Context OperatorsВ. equal. not_equal Test for equality. regex_match. not_regex_match Match against a regular expression (full match). regex_contains. not_regex_contains Match against a regular expression (partial match. Command ModeВ. Sublime Text provides a command_mode setting to prevent key presses from being sent to the buffer. This is useful, for example, to emulate Vim s modal behavior. Key bindings not intended for command mode (generally, all of them) should include a context like this. This way, plugins legitimately using command mode will be able to define appropriate key bindings without interference. Bindable KeysВ. Keys in key bindings may be specified literally or by name. If using a name doesn t work in your case, try a literal value. Here s the list of all valid names. Warning about Bindable KeysВ. If you re developing a package, keep this in mind. Ctrl+Alt+ alphanum should never be used in any Windows key bindings. Option+ alphanum should never be used in any OS X key bindings. In both cases, the user s ability to insert non-ASCII characters would be compromised otherwise. End-users are free to remap any key combination. Order of Preference for Key BindingsВ. Key bindings in a keymap file are evaluated from the bottom to the top. The first matching context wins. Keeping Keymaps OrganizedВ. Sublime Text ships with default keymaps under Packages/Default. Other packages may include keymap files of their own. The recommended storage location for your personal keymap files is Packages/User. International KeyboardsВ. Due to the way Sublime Text maps key names to physical keys, key names may not correspond to physical keys in keyboard layouts other than US English. To enable logging related to keymaps, see.
PREVIOUS NEXT