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.

  • ctrl
  • control
  • alt
  • altgr - Linux 4050
  • option - Mac
  • command - 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:

a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
0
1
2
3
4
5
6
7
8
9
,
.
\
/
;
'
`
+
-
=
[
]
up
down
left
right
insert
home
end
pageup
pagedown
backspace
delete
tab
enter
pause
escape
space
keypad0
keypad1
keypad2
keypad3
keypad4
keypad5
keypad6
keypad7
keypad8
keypad9
keypad_period
keypad_divide
keypad_multiply
keypad_minus
keypad_plus
keypad_enter
clear
f1
f2
f3
f4
f5
f6
f7
f8
f9
f10
f11
f12
f13
f14
f15
f16
f17
f18
f19
f20

"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"]}
    }
]