130
votes

I'm trying to use the multi cursor functionality of vscode on a large(ish) file. the file is too large to select every line individually with ctrl-alt-up or down. In sublime-text I would select everything and push ctrl-shift-l. Is there a similar thing in vscode. I've tried using a regex search for ^, but that gives me an error stating "Expression matches everything".

6

6 Answers

245
votes

The command Selection / Add Cursors to Line Ends altshifti will put a cursor on every line in the current selection. (For mac use optshifti)

Tip: You can pull up the keyboard shortcut reference sheet with ctrlk,ctrls (as in, those two keyboard combos in sequence). (For mac use cmdk,cmds)

28
votes

Hold Alt+Shift and select the block. Then press End or Right button. You get selected individual lines.

I use version VSCode 1.5.3 in Windows.

21
votes
  • Hold Alt+Shift+i

  • Hold Home (fn+-> Mac) for right-most or End for left most(fn+<- Mac)

enter image description here

7
votes

This feature is actually called split selection into lines in many editors.

  • Sublime Text uses the default keybinding, CTRLSHIFT L
  • VSCode uses ALTSHIFTI
  • For Atom you actually need to edit your keymap to something like this
'.platform-win32 .editor, .platform-linux .editor':
  'ctrl-shift-L': 'editor:split-selections-into-lines' 
1
votes

Install the extension Sublime Commands.

[Sublime Commands] Adds commands from Sublime Text to VS Code: Transpose, Expand Selection to Line, Split into Lines, Join Lines.

(Don't forget to add the keybinding(s) from the extensions details page to your keybindings.json)


Doesn't VS Code already have a "split into lines" command?

Yes, yes it does. However it differs from the one in Sublime.

In VS Code, when you split into lines your selection gets deselected and a cursor appears at the end of each line that was selected (except for the last line where the cursor appears at the end of the selection).

In Sublime, when you split into lines a cursor appears at the end of each line (with the same exception as in VS Code) and the selection is divided on each line and "given" to the same line.

0
votes

I have the same problem, i'm used to Alt + drag to do 'box selections' in visual studio but it does'n work in code.

It seems to be impossible for now to do it differently than by selecting every single line.

However plugins should be supported soon so we will likely see a plugin for this if not implemented directly by microsoft.

From visual studio uservoice forums:

We plan to offer plugin support for Visual Studio Code. Thank you for your interests and look for more details in our blog in the coming weeks. http://blogs.msdn.com/b/vscode.

For the preview we are looking for exactly this type of feedback. Keep it coming.

Sean McBreen – VS Code Team Member