7

Some people who move from Visual Studio Code (VSC) to Visual Studio (VS) want to get VS to use the same key bindings as VSC, and there seems to be a way to do so.

I want to do the reverse. My main editor is VS, and there are some files that I want to edit on VSC, so I want the key bindings on VSC to behave like VS.

In particular, I'm interested in the rectangular, or multiline editing capabilities. In VS, I can Alt-Shift-Arrow to create a rectangular selection, which I find very useful:

I want to do the same in VSC. The closest I've found is the "multi-cursor" functionality, which kinda-ish sorta-ish works in a similar way:

However, there are two key differences with how VS works, which make it a bit frustrating to use:

  • The key bindings I've found are only for adding cursors. If I select too much, I can't refine my selection -- I have to start from scratch.
  • The cursors have to be in valid cursor locations. I can't add arbitrary locations to my selection like in VS. This is particularly useful when adding and removing single-line comments to a large area of code, which may include empty lines.

Is there a way to get VSC to do rectangular selection, just like VS?

starball
  • 20,030
  • 7
  • 43
  • 238
Panda Pajama
  • 1,283
  • 2
  • 13
  • 31

1 Answers1

5

Move the caret to the desired anchor point for the rectangular selection, then, while holding shift+alt (windows/linux) or shift+option (macos), click the other corner of the desired rectangular selection.

See also the dedicated VS Code user docs for "Column (box) selection" and this post on superuser.com: Selecting columns in Visual Studio Code.

For keyboard-only usage, just use whatever keyboard shortcut is bound to the editor.action.insertCursorAbove and editor.action.insertCursorBelow keyboard commands to add cursors vertically, and then select horizontally with shift + arrow keys (and optionally other modifiers). To find out what keyboard shortcut you have bound to that keyboard command, search for it in the keyboard shortcut editor UI.

starball
  • 20,030
  • 7
  • 43
  • 238