Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select multiple lines with cursors at each line start

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

ctrl + shift + L and then put cursor at beginning of each line

like image 692
Z.Tiny Avatar asked Mar 02 '18 10:03

Z.Tiny


3 Answers

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.

like image 73
ochs.tobi Avatar answered Nov 20 '22 15:11

ochs.tobi


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.

like image 28
Maxime Avatar answered Nov 20 '22 17:11

Maxime


  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.

like image 43
Mark Avatar answered Nov 20 '22 17:11

Mark