Multiple selections (multi cursor) in Visual Studio 2022 and VS Code

Visual Studio 2022 Multiple Selections

For a while I thought it was only available in vs code until I found this post

https://stackoverflow.com/a/52015155

Basically it states that multi cursor edit is natively supported in Visual Studio starting from version 2017 Update 8🥳

The keyboard shortcuts are slightly different between Visual Studio 2022 and VS Code. Below are the shortcuts for Visual Studio 2022 (and back to 2017 Update 8)

  • Ctrl + Alt + click : Add a secondary caret
  • Ctrl + Alt + double-click : Add a secondary word selection
  • Ctrl + Alt + click + drag : Add a secondary selection
  • Shift + Alt + . : Add the next matching text as a selection
  • Shift + Alt + ; : Add all matching text as selections
  • Shift + Alt + , : Remove last selected occurrence
  • Shift + Alt + / : Skip next matching occurrence
  • Alt + click : Add a box selection
  • Esc or click : Clear all selections

Multiple selections (multi-cursor) in vs code

VS Code supports multiple cursors for fast simultaneous edits. You can add secondary cursors (rendered thinner) with Alt+Click. Each cursor operates independently based on the context it sits in. A common way to add more cursors is with Ctrl+Alt+Down or Ctrl+Alt+Up that insert cursors below or above.

Note: Your graphics card driver (for example NVIDIA) might overwrite these default shortcuts.

Multi-cursor

Ctrl+D selects the word at the cursor, or the next occurrence of the current selection.

Multi-cursor-next-word

Tip: You can also add more cursors with Ctrl+Shift+L, which will add a selection at each occurrence of the current selected text.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *