Search code examples
sublimetext3sublimetextkey-bindings

Keybinding alt+up won't work in Sublime Text 3


I want to copy the Move Line Up/Down keyboard shortcut of VS Code to Sublime Text 3 which uses Ctrl+Up/Ctrl+Down key bindings, so I placed the following in the User-defined key-bindings file:

[
    {
        "keys": ["alt+up"], "command": "swap_line_up",
        "keys": ["alt+down"], "command": "swap_line_down"
    }
]

The swap_line_down works but the swap_line_up doesn't. I've already checked for conflicts within Default(Windows).sublime-keymap. I've tried to swap the commands to check if the problem is specific with alt+up

[
    {
        "keys": ["alt+up"], "command": "swap_line_down",
        "keys": ["alt+down"], "command": "swap_line_up"
    }
]

and, indeed, now swap_line_up works but swap_line_down doesn't. So it seems alt+up is the problem. What seems to be the issue here?


Solution

  • Your key bindings aren't specified correctly; each binding object should have a single keys and command (and optionally a single args and context key s well), but you have both specified in a single binding.

    It should look more like this:

    [
        {
            "keys": ["alt+up"], "command": "swap_line_up",
        },
        {
            "keys": ["alt+down"], "command": "swap_line_down"
        },
    ]