This guide is deprecated. New content at docs.sublimetext.info
Key bindings map key presses to commands.
Key bindings are stored in .sublime-keymap files and defined in JSON. All key map file names need to follow this pattern: Default (<platform>).sublime-keymap. Otherwise, Sublime Text will ignore them.
Each platform gets its own key map:
Separate key maps exist to abide by different vendor-specific HCI guidelines.
Key maps are arrays of key bindings. Below you’ll find valid elements in key bindings.
Here’s an example illustrating most of the features outlined above:
{ "keys": ["shift+enter"], "command": "insert_snippet", "args": {"contents": "\n\t$0\n"}, "context":
[
{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\{$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\}", "match_all": true }
]
}
Sublime Text provides a command_mode setting to prevent key presses from being sent to the buffer. This is useful to emulate Vim’s modal behavior.
Keys may be specified literally or by name. Below you’ll find the list of valid names:
In both cases, the users ability to insert non-ascii characters would be compromised.
Sublime Text ships with default key maps under Packages/Default. Other packages may include their own key map files. The recommended storage location for your personal key map is Packages/User.
See Merging and Order of Preference for information about how Sublime Text sorts files for merging.
Due to the way Sublime Text maps key names to physical keys, there might be a mismatch between the two.
See sublime.log_commands(flag) to enable command logging. It may help when debugging key maps.