14

I want to select multiple lines and put a cursor at the beginning of each line. Sublime Text can do this with Ctrl-Shift-L select multiple lines:

enter image description here

Ctrl + Shift + L and then put cursor at beginning of each line:

enter image description here

Penny Liu
  • 15,447
  • 5
  • 79
  • 98
Z.Tiny
  • 149
  • 1
  • 1
  • 3

5 Answers5

19

Press Crtl + Shift + Alt + Arrow up/down to select multiple lines in Visual Studio Code. Note that the selected lines will be in one column (if possible).

You can also mark some lines and then do this combination and you have all selected lines included.

Moreover you can press and hold Alt and click the lines you need. This way you can select multiple lines that are not neighbours or in the same column.

ochs.tobi
  • 3,214
  • 7
  • 31
  • 52
  • 3
    It is possible to press and hold ALT and click with the mouse cursor at the points you need and you will have a multi cursor to write or select ad different places instead of only in a column. – ChW Mar 02 '18 at 10:31
  • On Linux, Shift+Alt allows you to drag the mouse to select consecutive columns. – skytaker Oct 29 '18 at 14:57
  • 2
    On macOS it is thus "shift+⌥" (Shift+Option) and then select/drag the mouse. – Eugéne May 22 '20 at 08:20
15

To do exactly what Ctrl-Shift-L does in Sublime Text, you must do:

On Windows:

  1. Select the lines.

  2. Alt-Shift-I (will add multiple cursors)

  3. Shift-Home (will go at the beginning of each line and be selected)

On Mac :

  1. Select the lines.

  2. alt-shift-I (will add multiple cursors)

  3. cmd-shift- (will go at the beginning of each line and be selected)

More information in this answer.

Maxime
  • 8,645
  • 5
  • 50
  • 53
  • 1
    This puts the cursors at the end - the OP wants them at the beginning - easily fixed with Function - Home. But the OP also wants the lines selected. So doing another Ctrl-I does accomplish what the OP wants. See my alternate answer above. – Mark Apr 18 '18 at 18:32
  • I adjusted the answer – Maxime Apr 18 '18 at 18:38
  • on Mac, alt or option key (depending on model) – NineCattoRules Feb 26 '23 at 10:30
  • The command is titled "Add Cursors to Line Ends" and its command ID is `editor.action.insertCursorAtEndOfEachLineSelected`. Might be helpful if you want to change the default shortcut. – Raine Revere Aug 21 '23 at 15:25
4
  1. Put cursor at beginning of first line
  2. Ctrl-Shift-Alt-Arrow down/up will put a cursor at the beginning of the following/preceding lines

  3. Ctrl-I will select those lines with the cursor at the beginning of each line.

NOTE : On my vscode the cursors look like they might be shifted down one line but they actually are not - the are in the right place. If you start typing, it works but you have to hit Enter when you are done to get back separate lines. It is a little quirky but works as you would expect.

EDIT (using a hint from @Maxime's answer)

  1. Select your test first.
  2. Alt-Shift-I : puts cursors at the end of each of those lines but text unselected (I as in island not a lowercase L)
  3. Function-Home : put cursors at beginning of each line.
  4. Ctrl-I : selects all lines.

Important: read the NOTE above.

--------------------- v1.43 see How to put the cursor at the end of all selected lines in Visual Studio Code? with column selection mode it is easy to put the cursor at the beginning or end of lines selected by dragging.

Mark
  • 143,421
  • 24
  • 428
  • 436
3

You can hold alt and click the places you need with the mouse. This way you can select rows that aren't related, like row 10,15,18. Also you can select at different places in the same row.

1

I hope this helps someone, but there is a setting in VSCode called Editor: Multi Cursor Modifier which may do what OP is asking:

Editor: Multi Cursor Modifier setting

Ralph David Abernathy
  • 5,230
  • 11
  • 51
  • 78