81

I'm on a Mac. I have 7 columns in Sublime Text 3, each 300 lines each. If possible, I would like to select only the 4th column using a single keyboard shortcut.

Unsuitable options

  • ctrl + shift + up/down
  • alt + mouse + drag
  • ctrl + alt + up/down. (This actually doesn't do anything, nor does it appear in my console session and nor is it a single keyboard shortcut).
  • I'd also prefer not to use VI/VIM mode just for this as it's not regular part of my workflow

What I've tried:

  • A macro: but it isn't specific enough.
  • using command and 'page down' with ctrl and 'shift`: no luck
  • SublimeText 3 Column-Select plugin: did not seem to work for me

My ideal solution would be that my cursor could be placed anywhere in a column and I would hit a shortcut (e.g. ctrl-alt-shift-a) and it would select the whole column.

Here is an example:

John Sally Benson Mariah Patrick Samantha Martin

Simon Kate Carey Delores Joshua Samuel Eliza

I want to select the column with Maria and Delores with one keystroke. I perform this action often so for various reasons (cut/paste, change case, append, add quotes, run macro etc) and thus would want something quick and repeatable.

How would I do this?

user2544542
  • 1,423
  • 1
  • 14
  • 16
  • I couldn't find a satisfactory answer in this thread. I did find one here though: https://stackoverflow.com/questions/10080202/how-can-i-do-a-column-select-across-the-entire-file – marvin Feb 17 '18 at 22:37

9 Answers9

169

You should see Sublime Column Selection:

Using the Mouse

Different mouse buttons are used on each platform:

OS X

  • Left Mouse Button +
  • OR: Middle Mouse Button

  • Add to selection:

  • Subtract from selection: +

Windows

  • Right Mouse Button + Shift
  • OR: Middle Mouse Button

  • Add to selection: Ctrl

  • Subtract from selection: Alt

Linux

  • Right Mouse Button + Shift

  • Add to selection: Ctrl

  • Subtract from selection: Alt

Using the Keyboard

OS X

  • Ctrl + Shift +
  • Ctrl + Shift +

Windows

  • Ctrl + Alt +
  • Ctrl + Alt +

Linux

  • Ctrl + Alt +
  • Ctrl + Alt +
Stevoisiak
  • 23,794
  • 27
  • 122
  • 225
Mithril
  • 12,947
  • 18
  • 102
  • 153
  • 44
    Windows Note: For people using certain graphics cards (Intel), there are HotKeys setup that causes `Ctrl + Alt + Down` to rotate your screen. You need to disable these HotKeys for this to work on Windows. `Ctrl+Alt+F12 > Options > Uncheck "Enable Hot Keys"` – L_7337 Apr 27 '16 at 13:01
  • 3
    The question specified *without mouse* and the selection should be made of the *entire column* all at once. This answer does not meet that. – user2544542 Oct 18 '16 at 15:02
  • 18
    On Linux Mint, `Ctrl + Alt + Up/Down` didn't work for me. Using `Alt + Shift + Up/Down` instead. – a06e Oct 27 '16 at 14:38
  • 2
    I am using sublime3 on macosx and to enter column mode i select a portion of text as usual, but then i press a shortcut to "place a carret on each line of the selection": `⌘` + `SHIFT` + `L` – isaias-b Nov 03 '17 at 12:44
  • 2
    On Ubuntu 16.04, `Ctrl + Alt + Up/Down` switches virtual workspace. `Alt + Shift + Up/Down`, as becko said above, works. – Tor Klingberg May 09 '18 at 12:09
  • This is not a good answer past 10k lines or so. – ThickMiddleManager Aug 27 '22 at 13:18
25

The reason why the sublime documented shortcuts for Mac does not work are they are linked to the shortcuts of other Mac functionalities such as Mission Control, Application Windows, etc. Solution: Go to System Preferences -> Keyboard -> Shortcuts and then un-check the options for Mission Control and Application Windows. Now try "Control + Shift [+ Arrow keys]" for selecting the required text and then move the cursor to the required location without any mouse click, so that the selection can be pasted with the correct indentation at the required location.

abhishektalluri
  • 391
  • 3
  • 5
  • Should be noted in the "correct answer". Also quite annoying the shortcuts do not exactly match in the settings. ie: In the "Shortcuts" is just looks like https://i.imgur.com/v5tm9Tl.png – wenbert Nov 27 '17 at 01:46
16

In my case (Linux) is alt+shift up/down

 { "keys": ["alt+shift+up"], "command": "select_lines", "args": {"forward": false} },
 { "keys": ["alt+shift+down"], "command": "select_lines", "args": {"forward": true} },    
Nishant
  • 20,354
  • 18
  • 69
  • 101
Math
  • 768
  • 1
  • 8
  • 18
10

This should do it:

  1. Ctrl+A - select all.
  2. Ctrl+Shift+L - split selection into lines.
  3. Then move all cursors with left/right, select with Shift+left/right. Move all cursors to start of line with Home.
Sanchay
  • 1,053
  • 1
  • 16
  • 33
9

The SublimeText 3 Column-Select plugin should be all you need. Install that, then make sure you have something like the following in your 'Default (OSX).sublime-keymap' file:

    // Column mode
    { "keys": ["ctrl+alt+up"], "command": "column_select", "args": {"by": "lines", "forward": false}},
    { "keys": ["ctrl+alt+down"], "command": "column_select", "args": {"by": "lines", "forward": true}},
    { "keys": ["ctrl+alt+pageup"], "command": "column_select", "args": {"by": "pages", "forward": false}},
    { "keys": ["ctrl+alt+pagedown"], "command": "column_select", "args": {"by": "pages", "forward": true}},
    { "keys": ["ctrl+alt+home"], "command": "column_select", "args": {"by": "all", "forward": false}},
    { "keys": ["ctrl+alt+end"], "command": "column_select", "args": {"by": "all", "forward": true}}

What exactly about it did not work for you?

rtorres
  • 2,601
  • 3
  • 27
  • 33
DrStrangepork
  • 2,955
  • 2
  • 27
  • 33
  • It didn't select the whole column. Was only able to get it to do incremental selection up or down a column line-by-line. – user2544542 Jun 28 '15 at 09:51
  • See my update regarding the Default (OSX).sublime-keymap file – DrStrangepork Jul 06 '15 at 17:17
  • The bottom two (with home and end) are what I'm interesting in but it doesn't seem to work. – user2544542 Jan 31 '16 at 11:26
  • Assuming you do not have a keymap that overrides those in the plugin, ctrl+alt+home should select the current column of your cursor up to the first line of the file. That is to say that if you have the cursor in Line 3, Column 3 and hit ctrl+alt+home, you should see a line that runs from Line 3, Column 3 to Line 1, Column 3. Hitting ctrl+alt+home again should return you to just Line 3, Column 3. Hitting ctrl+alt+end does the same thing to the last line of the file. Then use the standard selection keys to select your text. – DrStrangepork Feb 02 '16 at 18:12
4

For macOS, you don't need install any plugin or mouse. just do like this :- Ctrl+Shift+Down

Sanchay
  • 1,053
  • 1
  • 16
  • 33
vincent
  • 142
  • 1
  • 2
  • 7
2

Alright, here's the best solution I've found that meets all the requirements:

  1. Download the Sublime-Text-Advanced-CSV Sublime plugin and install.
  2. Specify a delimiter for your column (default is ","), via the "CSV: Set Delimiter" command.
  3. Hit "ctrl + , s" (or select from Command Palette) and your column will be selected.

No need for mouse interaction whatsoever.

user2544542
  • 1,423
  • 1
  • 14
  • 16
0

Commenting just so people can have a solution to the intended question.

You can do what you are wanting but it isn't quite as nice as Notepad++ but it may work for small solutions decently enough.

In sublime if you hold ctrl, or mac equiv., and select the word/characters you want on a single line with the mouse and still holding ctrl go to another line and select the word/characters you want on that line it will be additive and you will build your selection. I mainly use notepadd++ as my extractor and data cleanup and sublime for actual development.

The other way is if your columns are in perfect alignment you can simply middle click on windows or option + click on mac and this enables you to select text in a square like fashion, Columns, inside the lines of text.

David
  • 17
  • 2
  • The question was for a keyboard shortcut ONLY option (no mouse, no dragging) that would select the entire column at once, on a mac. – user2544542 Feb 04 '17 at 22:43
-2

I know notepad++ has a feature that lets you select blocks of text independent of line/column by holding control + alt + drag. So you can select just about any block of text you want.

Akado117
  • 57
  • 7
  • Notepad++ is Windows-only, OP is on a Mac. You'll also note OP specifically said this was not an option... – MattDMo Aug 01 '14 at 18:31
  • 2
    Shift + Right mouse button (not left) in Linux. – hipokito Nov 30 '15 at 20:00
  • @MattDMo Notepad++ runs great with Wine. I moved from Notepad++ to Geany&SublimeText and that feature was the first that I look for. Geany does it by `Ctrl+Alt+Left Mouse` selection. – m3nda Dec 14 '15 at 13:44