1

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?

marshblocker
  • 83
  • 1
  • 6
  • 1
    What do you see if you open the Sublime console with `View > Show Console`, enter `sublime.log_input(True)` and then press that key sequence? If the answer is "nothing", then some external program is eating the key before Sublime can see it. – OdatNurd Dec 04 '21 at 20:20
  • @OdatNurd It returns `key evt: alt+up`. – marshblocker Dec 04 '21 at 22:39

1 Answers1

3

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"
    },
]
OdatNurd
  • 21,371
  • 3
  • 50
  • 68