7

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

8

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

4
  • After that how can you go to the end of the lines for all cursors? – aless80 Jun 21 '17 at 13:58
  • @aless80 then you work just like with one cursor, all combinations are the same. Go to the end of the line - press End. – bruha Jun 22 '17 at 7:04
  • @bruha Sorry, now I see that that was possible. When I wrote my previous command I could not make it work – aless80 Jun 22 '17 at 13:12
  • There's also the keyboard shortcut. On my stinking Ubuntu 18.04 it was broken for some reason though, so I fixed it. Full explanation here: superuser.com/questions/641292/…. – Gabriel Staples Jul 15 '20 at 2:55
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.

1
  • 2
    The OP already knows that they can hold Ctrl to achieve that, but they want it with the middle mouse button. – slhck Sep 5 '13 at 10:17
5

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

3
  • 2
    Does not work on Ubuntu 16 for me. – Evan Oct 29 '19 at 16:41
  • This works on one of my Ubuntu 18.04 computers, but not the other. I'd really like to know what's going on. – Gabriel Staples Jul 15 '20 at 2:32
  • Solved it! That's been bothering me for MONTHS! What a pain! superuser.com/a/1568729/425838 – Gabriel Staples Jul 15 '20 at 2:53
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).

1

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 this? 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.

1
  • 1
    thank you for that wholesome answer – john Smith Jul 15 '20 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.