leifg
leifg

Reputation: 8988

Turn multiline selection into multi cursor selection in VSCode

It happens from time to time that I need to edit 100+ lines in a text file all at once.

I know I can use ⌘ Cmd+/ to select multiple lines but depending on the size of the file that takes a while.

In Atom and Sublime, I can just do a ⌘ Cmd + a to select everything, hit another shortcut (forgot the actual shortcut) and end up with a cursor for every line.

Have not found this in VSCode.

Upvotes: 15

Views: 5973

Answers (2)

molaro
molaro

Reputation: 520

FWIW cursorLineStart is not the opposite of Shift-Alt-I. In looking at the commends, Shift-Alt-I is "Add cursors to line ends", but there is not a "Add cursors to line begins" option.

However, the easy trick for that is:

  1. Select your text block
  2. Shift-Alt-I to put a cursor at the end of each line
  3. Command-LeftArrow will move those cursors to the beginning of the lines

Its an extra step but it works. When I get time I will play around with building a custom command to do all this in one action.

Upvotes: 0

Mark
Mark

Reputation: 180631

Ctrl-a to select all. (or whatever muli-line selection you want)

Shift-alt-I will put cursors at end of each selected line.

And then if you want those cursors at the beginning of each line you need to trigger the command "cursorLineStart" which is unbound by default. Give it a keybinding and all those end-of-line cursors will jump to the beginning of each line.


With v1.43 and Column Selection Mode this can be quite easy, see Column selection like Visual Studio and How to put the cursor at the end of all selected lines in Visual Studio Code?

Upvotes: 28

Related Questions