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?
On Windows, press Alt + Z (macOS: Option ⌥ + Z ) to toggle word wrapping, or, select View > Toggle Word Wrap from VSCode Menu. Show activity on this post. For Windows, Pressing Alt+Z will break the line.
Place your cursor somewhere in or next to the word you wish to select. Press Alt-F3 (Windows or Linux) or Command+Ctrl+G (Mac OS X) to highlight every instance of the word in the document. Type to replace the selected words with your changes.
Select an entire line of text by holding down the "Shift" key and pressing "End", if you are at the beginning of the line, or "Home" if you are at the end of the line. Select an entire paragraph by placing your cursor at either the beginning or the end of that paragraph.
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".
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With