Skip to content

User `keymap.json`

Arun Bose edited this page Feb 7, 2024 · 1 revision

The keymap.json file allows users to customize and override default key bindings for commands.

JSON Data Format

The JSON data format is:

{
    "overrides": {
        "<key>": "<command-id>"
        [, "<key>": "<command-id>"]
    }
}

Where:

<key> is a unique key. <command-id> is the command id string to assign, or null to remove a key binding.

Modifier keys are operating system specific, so on Mac use Cmd versus Ctrl on Windows. The following table lists all the valid modifier keys and other supported key names.

Windows/Linux Mac Notes
Ctrl Cmd
Alt Opt
Shift Shift
Ctrl Control key only available on Mac
Up Up displayed as ↑ on mac
Down Down displayed as ↓ on mac
Left Left displayed as ← on mac
Right Right displayed as → on mac
Backspace Backspace
Enter Enter
Tab Tab
Space Space
PageUp PageUp
PageDown PageDown
Home Home
End End
Insert Insert
Delete Delete

Command ID can be found in in the shortcuts panel when this file is opened.

Exceptions

Special Commands

Currently, the shortcuts to these commands cannot be updated or re-assigned:

  • key: Ctrl/Cmd-A, command: "edit.selectAll"
  • key: Ctrl/Cmd-C, command: "edit.copy"
  • key: Ctrl/Cmd-V, command: "edit.paste"
  • key: Ctrl/Cmd-X, command: "edit.cut"
  • key: Ctrl/Cmd-Z, command: "edit.undo"
  • key: Ctrl/Cmd-Y, Cmd-Shift-Z, command: "edit.redo"

Mac Reserved Shortcuts

These shortcuts cannot be overridden on Mac:

  • "Cmd-,"
  • "Cmd-H"
  • "Cmd-Alt-H"
  • "Cmd-M"
  • "Cmd-Q"

Eg. Mac key bindings from Sublime Text

{
    "overrides": {
        "Cmd-Shift-L":     "edit.splitSelIntoLines",
        "Ctrl-Shift-Up":   "edit.addCursorToPrevLine",
        "Ctrl-Shift-Down": "edit.addCursorToNextLine",
        "Cmd-Shift-D":     "edit.duplicate",
        "Ctrl-Shift-K":    "edit.deletelines",
        "Cmd-L":           "edit.selectLine",
        "Cmd-D":           "cmd.addNextMatch",
        "Cmd-Opt-1":       "cmd.splitViewNone",
        "Cmd-Opt-2":       "cmd.splitViewVertical",
        "Cmd-Opt-Shift-2": "cmd.splitViewHorizontal",
        "Ctrl-G":          "navigate.gotoLine",
        "Cmd-Opt-Right":   "navigate.nextDoc",
        "Cmd-Opt-Left":    "navigate.prevDoc",
        "Cmd-R":           "navigate.gotoDefinition",
        "Cmd-P":           "navigate.quickOpen"
    }
}

Eg. Windows key bindings from Sublime Text

{
    "overrides": {
        "Ctrl-Shift-L":  "edit.splitSelIntoLines",
        "Ctrl-Alt-Up":   "edit.addCursorToPrevLine",
        "Ctrl-Alt-Down": "edit.addCursorToNextLine",
        "Ctrl-Shift-D":  "edit.duplicate",
        "Ctrl-Shift-K":  "edit.deletelines",
        "Ctrl-D":        "cmd.addNextMatch",
        "Alt-Shift-1":   "cmd.splitViewNone",
        "Alt-Shift-2":   "cmd.splitViewVertical",
        "Alt-Shift-8":   "cmd.splitViewHorizontal",
        "Ctrl-R":        "navigate.gotoDefinition",
        "Ctrl-P":        "navigate.quickOpen"
    }
}