22

I cannot figure out how to do rectangular selection in Sublime Text 2 using only keyboard. What I seem to always come across is to do ctrl-shift-up or -down (which I assume mean arrow keys), as laid out here: https://stackoverflow.com/a/13796939/1022967

But when I try to use that, I must send an OS-level command, because what happens is that my window slowly recedes and shows me all of the open apps/windows I have going on my Mac (I forget what that's called -- like a dashboard of what I have running). This happens when I use this key chord in apps outside of Sublime Text 2 as well.

Do I have something misconfigured? Could I have alternate key chords to do this?

Community
  • 1
  • 1
mpettis
  • 3,222
  • 4
  • 28
  • 35

5 Answers5

37

You do not need to change the Sublime Text key bindings.

Simply go to System Preferences -> Keyboard -> Keyboard Shortcuts, click on Mission Control, and uncheck the boxes next to Mission Control and Application windows, then you will be able to use the default keys for column selection. This is a quick and easy fix, especially if you are not using Mission Control.

Michael Sheaver
  • 2,059
  • 5
  • 25
  • 38
23

Go to the menu:

Sublime Text -> Preferences -> Key Bindings - Default

What are you looking for is:

{ "keys": ["ctrl+shift+up"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["ctrl+shift+down"], "command": "select_lines", "args": {"forward": true} },

The actual keys might be different, you need to find "select_lines" commands with these arguments.

If you want to change the keys, you need to open Key Bindings - User in the menu, then copy-paste and edit these lines according to your needs.

You will notice the change immediately after saving the file, if it has proper format (JSON), otherwise you'll get an error message.

gatto
  • 2,947
  • 1
  • 21
  • 24
  • Thanks! This may be a separate thread/question, but how do I find a keyboard shortcut that doesn't conflict with an existing one? Other than going through the files and mentally keeping track? – mpettis Apr 30 '13 at 20:34
  • 2
    I don't think ST detects conflicts out of the box, but it's certainly possible to write a script that does this. Here, look at [this answer](http://stackoverflow.com/a/13562111/521590), there is a link to a plugin that does it. – gatto Apr 30 '13 at 20:58
  • 1
    This is the correct answer. I switched the bindings to `alt+shift+up` so I can use the option key instead of ctrl or command, which are both bound to system-level actions in 10.8.x. – geerlingguy Jun 03 '13 at 14:14
5

FWIW, on my MacBook Pro running OS X 10.8.5, I set the keyboard bindings for column selection mode in my "Key Bindings - User" file in Sublime. Setting the key binding at the Mac System level in System Preferences > Keyboard > Keyboard Shortcuts > Application Shortcuts doesn't work.

After looking through the Sublime "Key Bindings - Default" preferences file and my Mac system preferences to make sure I wouldn't break an existing key binding, I went with Ctrl+Alt+Shift+Up and Ctrl+Alt+Shift+Down for column selection.

Here's what I have in my Sublime "Key Bindings - User" file:

{ "keys": ["ctrl+alt+shift+up"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["ctrl+alt+shift+down"], "command": "select_lines", "args": {"forward": true} }

Hope this helps.

user2806827
  • 51
  • 1
  • 1
-1

For Mac, you need to use the command key, not control. So vertical select would be Command-Shift-Up/Down, horizontal is Command-Shift-Right/left

Both of the selection types go from where your cursor is currently so make sure your cursor is in the correct place you want it.

GossJ
  • 69
  • 8
  • 1
    Thanks for your response! On my bindings (which are default out-of-the-box), command-shift-up/down will select lines from my cursor to file beginning/end, respectively. I'm going to try gatto's solution below, but I asked there as well, how to tell which keystrokes are already defined. – mpettis Apr 30 '13 at 20:37
  • 1
    Same here - Mac OS X uses this command in general to select text to end/beginning of file. – geerlingguy Jun 03 '13 at 14:13
-1

Simplest solution, don't need to touch the bindings file. Hold down ALT key and make a selection using touchpad in 'clicked' state. It only selects the column.

G..
  • 1
  • 1