10

I just switched from Windows to Ubuntu 13.04 and I'm missing a function in Sublime Text,

On Windows I used the middle mouse button to set multiple cursors (a bit like holding Ctrl and adding cursors but instead of click for each cursor jsut hold the middle mousebtn) but now on Ubuntu I can't find anything like that.

How can I get this functionality back?

is there any super user out there? for any hint thanks in advance

5 Answers5

10

Shift+Right Mouse Button is the combination for column selection in Linux.

bruha
  • 216
  • 2
  • 4
9

Alt+Shift+Up Will Add a new cursor on the line above the current one

Alt+Shift+Down Will Add a new cursor on the line under the current one

n0p
  • 173
5
  • Ctrl + Mouse1Click will set another cursor at the location of the click.

  • Ctrl + D will highlight the current word, move the cursor to its end, and add another highlight and cursor at the next occurence of that word. Repeated presses will select additional occurences.

rld.
  • 524
3

Using/enabling "multi-cursor", "select lines", or "column selection" mode in Sublime Text 3

  1. As @bruha says, Shift + Right-mouse-click and drag up or down works.
  2. As @russianPopsv says, these should work on Ubuntu too:
    1. Alt+Shift+Up
    2. Alt+Shift+Down

In my case, however, on two Ubuntu 18.04 machines Alt+Shift+Up worked just fine, but on a third one it wouldn't work at all! I have no idea why. How do I fix it?

If it doesn't work for you, then do this:

In Sublime Text 3, go to Preferences --> Key Bindings. Search the left screen for select_lines. There are two matches, here:

enter image description here

They contain these JSON configuration lines:

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

So, copy those into your personal settings screen on the right, so it looks like this. If you have other settings there already, be sure to keep those too.

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

Now save (Ctrl + S) and exit these keyboard settings by closing the window. That's it! The keyboard shortcuts will work now. I don't know why we had to do this, as they should have worked by default already, but somehow this fixed it, so whatever, it's good enough for me.

Where did I originally learn how to use multi-cursor ("column selection") mode in Sublime Text? Answer: Sublime Tutor

I originally learned this "column selection", or "multi-cursor" mode from Sublime Tutor (https://sublimetutor.com/). It is described in chapter_3_2.md, as shown here:

enter image description here

It will help you master Sublime Text in no time! It's super super easy to install:

(See: https://packagecontrol.io/packages/Sublime%20Tutor):

Installation

Via Package Control:

  1. Install Package Control if already not installed: https://packagecontrol.io/installation#st3
  2. Press Cmd+Shift+P to bring command palette in front
  3. Type Install Package and press enter.
  4. Search for Sublime Tutor and press enter to install the plugin.

I highly recommend it.

2

Copy the relevant mousemap settings from the Windows file to the Linux file.

Windows file: *~/.config/sublime-text-2/Packages/Default/Default (Windows).sublime-mousemap*

You could copy the settings to the linux file in the same directory, however I recommend adding a file in your user folder: *~/.config/sublime-text-2/Packages/User/Default (Linux).sublime-mousemap*

Relevant settings:

// Mouse 3 column select     
[{
  "button": "button3",
  "press_command": "drag_select",
  "press_args": {"by": "columns"}
},
{
  "button": "button3", "modifiers": ["ctrl"],
  "press_command": "drag_select",
  "press_args": {"by": "columns", "additive": true}
},
{
  "button": "button3", "modifiers": ["alt"],
  "press_command": "drag_select",
  "press_args": {"by": "columns", "subtractive": true}
}]

This is not included in the Linux settings by default because in linux, mouse 3 is paste. You can highlight something and use your mouse to paste (without having to copy).

d_rail
  • 2,989