34
votes

I'm trying to use the swap line keyboard shortcuts in sublime text 2.

I'm holding down command, ctrl, and up and down keys, but they're not doing anything.

Using the edit menu item works though. I'm using a small mac keyboard. What could be the problem thanks.

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

]
5

5 Answers

54
votes

cmd + ctrl + / on OS 10.8 running sublime text 2 do swap lines for me, by default. I did not need to bind any specific keys, nor does it appear to have any other function.

10
votes

ctrl + shift + / (on linux)

5
votes

Mac OSX 10.8, Sublime 3, small Mac keyboard:

Default behaviour didn't work for me, but then I copied the lines from Preferences > Key Bindings - Default to Preferences > Key Bindings - User. The moment I saved the user settings file, the keyboard shortcuts for swapping lines started to work.

2
votes

Correct me if I'm wrong, but doesn't cmd+up/down on the small mac keyboard bind to something else? I don't recall what up and down do, but I think left and right bind to home and end respectively.

Well anyways, to check, in the console enter sublime.log_input(True) then press the keys. It should tell you what key presses ST is actually receiving. If that is correct, enter sublime.log_commands(True) into the console to ensure the proper command is running. You can also try running https://github.com/skuroda/FindKeyConflicts to see if anything else is bound to that key combination in general. Disclaimer - I'm the author of FindKeyConflicts.

2
votes

Mac OSX 10.12 Sierra - Sublime Text 3:

I have problem at the default configuration “CMD + CTRL + Up arrow/Down arrow”, doesn’t work for me. Then I edit my User Key Bindings (Preferences > Key Bindings > User) and add this:

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

It’s works for me using “CTRL + ATL + Up arrow/Down arrow”