Documentation Key Bindings
Key bindings in Sublime Merge are defined by files ending in .sublime-keymap. Key bindings use JSON, with the top-level structure being an array. Each binding is a JSON object.
Example
The following is an example of the format of a .sublime-keymap file.
[
{
"keys": ["super+shift+b"],
"command": "show_command_palette",
"args": {"command": "create_branch"}
},
{
"keys": ["super+f"], "command": "toggle_search",
"context": [{"operator": "not_equal", "key": "merge_mode"}]
},
{ "keys": ["super+left"], "command": "navigate_back" },
{ "keys": ["super+right"], "command": "navigate_forward" },
]
Bindings
Each key binding requires two keys, "keys" and
"command". To pass args to a command, the
"args" key should be specified. To restrict a key
binding to a specific situation, the "context" key must
be included.
"keys" Key
The "keys" value must be an array of strings, where
each string contains a key press, comprised of a key and
any modifiers. When multiple key presses are present in the array,
the command will only be invoked if the presses are performed in
sequence.
A key binding for the Escape key
{
"keys": ["escape"],
"command": "noop"
}
A key binding for the key A with the modifier Ctrl
{
"keys": ["ctrl+a"],
"command": "noop"
}
Modifiers
The following modifiers may be combined with key names for each key press.
ctrlcontrolalt-
altgr- Linux 4050 option- Maccommand- Mac-
super- the Windows key on Windows and Linux, or ⌘ on Mac -
primary- Ctrl on Windows and Linux, or ⌘ on Mac
Key Names
Key names are specified either by the (non-shifted) character printed on the key, or a key name:
abcdefghijklm
nopqrstuvwxyz
0123456789
,.\/;'`+-=[]updownleftrightinserthomeendpageuppagedownbackspacedeletetabenterpauseescapespace
keypad0keypad1keypad2keypad3keypad4keypad5keypad6keypad7keypad8keypad9keypad_periodkeypad_dividekeypad_multiplykeypad_minuskeypad_pluskeypad_enterclear
f1f2f3f4f5f6f7f8f9f10f11f12f13f14f15f16f17f18f19f20
"command" Key
The "command" key specifies the name of the command to
execute when the key press(es) are detected.
{
"keys": ["super+left"],
"command": "navigate_back"
}
Currently there is no compiled list of all built-in commands. The names of many commands can be found by looking at the Default ({PLATFORM_NAME}).sublime-keymap and Main.sublime-menu files in the Default - Merge.sublime-package and Default.sublime-packagepackages. See the Packages documentation for information on where to find the package and view the contents.
"args" Key
The arguments to send to the "command" key may be
specified by a JSON object under the "args" key.
{
"keys": ["super+shift+b"],
"command": "show_command_palette",
"args": {"command": "create_branch"}
}
"context" Key
To allow for key bindings that react differently based on the
situation, the "context" key allows specifying one or
more conditions that must evaluate to true for the key binding to
be active.
The "context" value is an array of objects. Each object
must contain a "key" key that has a string value. A
key is one of a predefined list of values that may be compared using
an "operator" and "operand". The default
operator is "equal" and the default operand is
true.
For "key" values that deal with selections, an
additional key "match_all" is supported. This defaults
to false, which means the condition only needs to
evaluate to true for a single selection. If "match_all"
is true, then the condition must evaluate to true for
all selections.
The following is a list of valid context "key" values:
- "search_mode"
-
If the interface is in search mode
Valid operators:"equal","not_equal"
Operator type: boolean - "blame_mode"
-
If the interface is blaming a file
Valid operators:"equal","not_equal"
Operator type: boolean - "tree_mode"
-
If the interface is showing the tree for a commit
Valid operators:"equal","not_equal"
Operator type: boolean - "merge_mode"
-
If the interface is showing the merge tool
Valid operators:"equal","not_equal"
Operator type: boolean - "can_commit"
-
If it is possible for the user to commit
Valid operators:"equal","not_equal"
Operator type: boolean - "is_editing_commit"
-
If the user is editing a commit
Valid operators:"equal","not_equal"
Operator type: boolean - "has_modified"
-
If modified files exist in the working directory
Valid operators:"equal","not_equal"
Operator type: boolean - "has_untracked"
-
If untracked files exist in the working directory
Valid operators:"equal","not_equal"
Operator type: boolean - "has_staged"
-
If one or more files has been staged
Valid operators:"equal","not_equal"
Operator type: boolean - "command_status_visible"
-
If the command status overlay is currently shown
Valid operators:"equal","not_equal"
Operator type: boolean - "overlay_visible"
-
If an overlay (command palette or command status) is
currently shown
Valid operators:"equal","not_equal"
Operator type: boolean - "control"
-
The name of the control, currently only
"text_control"is supported
Valid operators:"equal","not_equal"
Operator type: string - "is_blame"
-
If a blame text control is focused
Valid operators:"equal","not_equal"
Operator type: boolean - "is_staged"
-
If a staged diff control is focused
Valid operators:"equal","not_equal"
Operator type: boolean - "is_diff"
-
If a diff control is focused
Valid operators:"equal","not_equal"
Operator type: boolean - "collapsible"
-
If the focused can be collapsed
Valid operators:"equal","not_equal"
Operator type: boolean
User Bindings
Users can customize their key bindings by creating a file named Default.sublime-keymap in their Packages/User/ directory.
For example, the following will create a key binding to clean up the current repo, via Super+Shift+g.
[
{
"keys": ["super+shift+g"],
"command": "git",
"args": {"argv": ["gc"]}
}
]