Reputation: 137524
Sublime Text has a super useful command Selection / Split into Lines to split a selection so that you have multiple cursors, one at the end of each line.
Splitting the Selection into Lines
Select a block of lines, and then split it into many selections, one per line, using:
- Windows/Linux: Ctrl+Shift+L
- Mac: ⇧+⌘+L
How can I do this in Visual Studio Code?
Upvotes: 35
Views: 35631
Reputation: 20791
The built-in VS Code command Add Cursors to Line Ends adds the cursors to the end of each line's selection (not to the end of each line, despite the command's misleading name). But it also deselects everything, leaving you with just the cursors. If that works for you, go for it.
In contrast, Sublime's Split into lines gives you those same cursors but also leaves your original selection intact (but broken down into many selections). That behavior is more powerful since it lets you act on those selections or tap left to go to the beginning of each selection or tap right to go to the end of each selection.
For those who want Sublime's behavior, this extension gives it to you: Sublime Commands. The default shortcut is as expected: Ctrl+Shift+L.
Upvotes: 9
Reputation: 137524
The command is 'Add Cursors to Line Ends' (found in the command palette or the Selection menu). The default keyboard shortcut is Shift+Alt+I.
If you're familiar with Sublime Text, you may prefer Ctrl+Shift+L as a shortcut. In File / Preferences / Keyboard Shortcuts (Json):
{
"key": "ctrl+shift+l",
"command": "editor.action.insertCursorAtEndOfEachLineSelected",
"when": "editorTextFocus"
},
This overrides a default keyboard shortcut, "Select all occurrences of current selection".
Upvotes: 45