Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Cursors in Sublime Text 2 Windows

I have installed Sublime Text 2 in windows and I am trying to use the multiple cursors feature.

Firstly I highlight the selection I am looking for (three lines).

Then I can press CTRL + D to select each re-occurrence, or ALT + F3 to select all. There are four repeats in my situation.

I now want to move the cursors in the middle of the three lines and add some information, to be added to all occurrences.

As soon as I click in the selection, the multiple selection is gone? Is there something I am doing wrong, I am sure it is wrong but as the documentation is so weak I cannot find out how?

like image 971
StuartM Avatar asked Feb 19 '13 17:02

StuartM


People also ask

How do I get multiple cursors?

A common way to add more cursors is with Shift+Alt+Down or Shift+Alt+Up that insert cursors below or above. Note: Your graphics card driver (for example NVIDIA) might overwrite these default shortcuts. Ctrl+D selects the word at the cursor, or the next occurrence of the current selection.

How do you select multiple lines in Sublime Text?

To select multiple regions using the keyboard, select a block of text, then press Ctrl+Shift+L to split it into one selection per line.

What is Ctrl D in sublime?

Ctrl + D in SublimeText is "Quick Add Next." This appears to be equivalent to Ctrl + B in Brackets, which is "Add next match to Selection" on the Find menu.

How do you select multiple lines on a keyboard?

Hold down the "Shift" key and press the up arrow, if you are at the end of the paragraph, or the down arrow, if you are at the beginning. If you are in any other section of the paragraph, this shortcut will allow you to select the remainder of the paragraph from your cursor to the end or beginning.


3 Answers

It's usually just easier to skip the mouse altogether--or it would be if Sublime didn't mess up multiselect when word wrapping. Here's the official documentation on using the keyboard and mouse for multiple selection. Since it's a bit spread out, I'll summarize it:

Where shortcuts are different in Sublime Text 3, I've made a note. For v3, I always test using the latest dev build; if you're using the beta build, your experience may be different.

If you lose your selection when switching tabs or windows (particularly on Linux), try using Ctrl + U to restore it.

Mouse

Windows/Linux

Building blocks:

  • Positive/negative:
    • Add to selection: Ctrl
    • Subtract from selection: Alt In early builds of v3, this didn't work for linear selection.
  • Selection type:
    • Linear selection: Left Click
    • Block selection: Middle Click or Shift + Right Click On Linux, middle click pastes instead by default.

Combine as you see fit. For example:

  • Add to selection: Ctrl + Left Click (and optionally drag)
  • Subtract from selection: Alt + Left Click This didn't work in early builds of v3.
  • Add block selection: Ctrl + Shift + Right Click (and drag)
  • Subtract block selection: Alt + Shift + Right Click (and drag)

Mac OS X

Building blocks:

  • Positive/negative:
    • Add to selection:
    • Subtract from selection: ⇧⌘ (only works with block selection in v3; presumably bug)
  • Selection type:
    • Linear selection: Left Click
    • Block selection: Middle Click or + Left Click

Combine as you see fit. For example:

  • Add to selection: + Left Click (and optionally drag)
  • Subtract from selection: ⇧⌘ + Left Click (and drag--this combination doesn't work in Sublime Text 3, but supposedly it works in 2)
  • Add block selection: ⌥⌘ + Left Click (and drag)
  • Subtract block selection: ⌥⇧⌘ + Left Click (and drag)

Keyboard

Windows

  • Return to single selection mode: Esc
  • Extend selection upward/downward at all carets: Ctrl + Alt + Up/Down
  • Extend selection leftward/rightward at all carets: Shift + Left/Right
  • Move all carets up/down/left/right, and clear selection: Up/Down/Left/Right
  • Undo the last selection motion: Ctrl + U
  • Add next occurrence of selected text to selection: Ctrl + D
  • Add all occurrences of the selected text to the selection: Alt + F3
  • Rotate between occurrences of selected text (single selection): Ctrl + F3 (reverse: Ctrl + Shift + F3)
  • Turn a single linear selection into a block selection, with a caret at the end of the selected text in each line: Ctrl + Shift + L

Linux

  • Return to single selection mode: Esc
  • Extend selection upward/downward at all carets: Alt + Up/Down Note that you may be able to hold Ctrl as well to get the same shortcuts as Windows, but Linux tends to use Ctrl + Alt combinations for global shortcuts.
  • Extend selection leftward/rightward at all carets: Shift + Left/Right
  • Move all carets up/down/left/right, and clear selection: Up/Down/Left/Right
  • Undo the last selection motion: Ctrl + U
  • Add next occurrence of selected text to selection: Ctrl + D
  • Add all occurrences of the selected text to the selection: Alt + F3
  • Rotate between occurrences of selected text (single selection): Ctrl + F3 (reverse: Ctrl + Shift + F3)
  • Turn a single linear selection into a block selection, with a caret at the end of the selected text in each line: Ctrl + Shift + L

Mac OS X

  • Return to single selection mode: (that's the Mac symbol for Escape)
  • Extend selection upward/downward at all carets: ⌃⇧⇡, ⌃⇧⇣ (See note)
  • Extend selection leftward/rightward at all carets: ⇧⇠/⇧⇢
  • Move all carets up/down/left/right and clear selection: , , ,
  • Undo the last selection motion: ⌘U
  • Add next occurrence of selected text to selection: ⌘D
  • Add all occurrences of the selected text to the selection: ⌃⌘G
  • Rotate between occurrences of selected text (single selection): ⌥⌘G (reverse: ⌥⇧⌘G)
  • Turn a single linear selection into a block selection, with a caret at the end of the selected text in each line: ⇧⌘L

Notes for Mac users

On Yosemite and El Capitan, ⌃⇧⇡ and ⌃⇧⇣ are system keyboard shortcuts by default. If you want them to work in Sublime Text, you will need to change them:

  1. Open System Preferences.
  2. Select the Shortcuts tab.
  3. Select Mission Control in the left listbox.
  4. Change the keyboard shortcuts for Mission Control and Application windows (or disable them). I use ⌃⌥⇡ and ⌃⌥⇣. They defaults are ⌃⇡ and ⌃⇣; adding to those shortcuts triggers the same actions, but slows the animations.

In case you're not familiar with Mac's keyboard symbols:

  • is the escape key
  • is the control key
  • is the option key
  • is the shift key
  • is the command key
  • et al are the arrow keys, as depicted
like image 111
Zenexer Avatar answered Sep 30 '22 13:09

Zenexer


In Sublime Text, after you select multiple regions of text, a click is considered a way to exit the multi-select mode. Move the cursor with the keyboard keys (arrows, Ctrl+arrows, etc.) instead, and you'll be fine

like image 30
JamieJag Avatar answered Sep 30 '22 13:09

JamieJag


Try using Ctrl-click on the multiple places you want the cursors. Ctrl-D is for multiple incremental finds.

like image 31
mswanberg Avatar answered Sep 30 '22 14:09

mswanberg