By josh / June 18, 2013

Sublime’s secret selection mode

You’ve done it, I’ve done it: Once in a while, everyone copy-pastes some code from the Internetz. No shame in less typing, right?

Only now your carefully formatted code has a block with line numbers and extra indentation:

$(function() {
  1. function typeLess() {
  2.    console.log("Copy-and-paste rulez!");
  3. };

Doubtless you could fix this with some fancy multi-line footwork. But wouldn’t it be easier to just lasso all of those extraneous characters and whack ’em in one go?

Notepad++, TextMate, Visual Studio and many other editors support a block selection mode that lets you “drag a square” to do just this.

But guess what? While multi-edit hogs all the glory, Sublime also features a column selection mode that’s quite useful in its own right.

To use Column Selection with the mouse on Windows and Linux, click and hold the middle mouse button (or scroll wheel) while dragging around the desired selection. On a Mac, press and hold Option while dragging.

Or for you keyboard jockeys, you can press Ctrl+Alt+Down Arrow or Ctrl+Shift+Up Arrow to enter column selection mode on Windows or Linux, or Ctrl+Shift+Down Arrow or Ctrl+Shift+Up Arrow on your Mac keyboard. Shift+Left Arrow and Shift+Right Arrow will expand the selection horizontally.

I’ve created my own mouse configuration on my Windows laptop that lets me use Ctrl+Shift+Left Click instead of trying to click and hold my scroll wheel.

If you’d like to use customization as a starting point, just create a file called Default (Windows).sublime-mousemap in your User directory, then add the following:

  // Mouse 3 column select
    "button": "button1", 
    "count": 1, 
    "modifiers": ["ctrl", "shift"],
    "press_command": "drag_select",
    "press_args": {"by": "columns"}

Mac fans can change their mouse behavior with a custom Default (OSX).sublime-mousemap file.

P.S. For more ways to streamline your Sublime Text workflow, check out:

About the author


Maslow - August 24, 2014

On my Mac I press Alt while selecting text and it works perfectly 🙂

Ivan - August 17, 2015

For column (vertical) selection on Linux you must use Right Mouse Button + Shift

Click here to add a comment

Leave a comment: