I heard Microsoft released a new editor called Visual Studio Code and it looks pretty good. One key feature that I need is multi-line edit and I can't seem to find anything about it having it.
-
Related post here.– RBTOct 21, 2017 at 3:05
-
2From April 2018 (version 1.23), we can use middle mouse button to select multiple columns. code.visualstudio.com/updates/…– Ahmad IsmailMay 28, 2018 at 3:20
-
Related solution here stackoverflow.com/a/55580788/585398– suraj_faleApr 8, 2019 at 19:51
5 Answers
Box Selecting
Windows & Linux: Shift + Alt + 'Mouse Left Button'
macOS: Shift + option + 'Click'
Esc to exit selection.
MacOS: Shift + Alt/Option + Command + 'arrow key'
-
11Is there any way to change this shortcut? I can't find the related entry in the key bindings.– GuiSimNov 3, 2016 at 16:17
-
4This just creates a selection from the current cursor, to where you click. What if you wanna just "drag a square" to create one, ala Sublime (middle-click mouse + drag) or VS (alt + drag)? Mar 9, 2018 at 2:13
-
1@AlexMcMillan You can start dragging from where you want the selection to start before you hold down Shift + Alt down to create a block selection as you describe it :)– BoregoreMar 16, 2018 at 7:38
-
1Fantastic. This is super useful though I don't understand why VS Code can't just be like every other major editor (on Windows) and use ALT+left mouse button to do this. Gotta be different, I suppose Nov 13, 2018 at 14:19
-
3It's a shame, that it is not working the same as in normal Visual Studio, especially because the combination of [Shift]+[Alt] changes language settings.– gtuJul 17, 2019 at 9:08
Press Ctrl+Alt+Down or Ctrl+Alt+Up to insert cursors below or above.
-
18Note: Your graphics card provider might overwrite these default shortcuts. Apr 26, 2016 at 13:40
-
4You may want to edit your shortcuts. Go to File > Preferences > Keyboard Shortcuts. As an example:[ { "key": "ctrl+alt+numpad2", "command": "editor.action.insertCursorBelow", "when": "editorTextFocus" },{ "key": "ctrl+alt+numpad8", "command": "editor.action.insertCursorAbove", "when": "editorTextFocus" } ] Apr 26, 2016 at 13:53
The shortcuts I use in Visual Studio for multiline (aka box) select are Shift + Alt + up/down/left/right
To create this in Visual Studio Code you can add these keybindings to the keybindings.json file (menu File → Preferences → Keyboard shortcuts).
{ "key": "shift+alt+down", "command": "editor.action.insertCursorBelow",
"when": "editorTextFocus" },
{ "key": "shift+alt+up", "command": "editor.action.insertCursorAbove",
"when": "editorTextFocus" },
{ "key": "shift+alt+right", "command": "cursorRightSelect",
"when": "editorTextFocus" },
{ "key": "shift+alt+left", "command": "cursorLeftSelect",
"when": "editorTextFocus" }
-
2This is good, but not great as it doesn't quite act the same as box selection in other applications. e.g. If I do
shift+alt+down
3 times and thenshift+alt+up
once, rather than undoing my last down arrow key press so that only 2 rows are selected, it adds the row above the 1st one I had selected, so I end up with 4 rows selected. Also, you need to pressEsc
to get out of the box selection mode. I wish VS Code would provide native keyboard-box-selection support, but this answer is the next best thing 👍 Apr 13, 2018 at 18:27
For multiple select in Visual Studio Code, hold down the Alt key and starting clicking wherever you want to edit.
Visual Studio Code supports multiple line edit.
-
2I expected this to work, but it doesn't. Instead it acts like a regular mouse-click-n-drag.– jmorenoNov 14, 2019 at 16:54
-
3@jmoreno I had the same issue - only Shift+Alt+Click worked, until I did this: go to Selection menu, and select Switch to Alt+Click for Multi-Cursor.– KonJan 7, 2020 at 20:31
-
You may also want to go to Selection and choose 'Switch to Ctrl+Click' for multi-cursor selection if you find alt clicking to not work.. Jan 22, 2020 at 21:41
On Windows it's holding down Alt while box selecting. Once you have your selection then attempt your edit.