Multiple select in Visual Studio?

Visual StudioVisual Studio-2012SelectionText EditorMulti Select

Visual Studio Problem Overview


Is there a way to select multiple non-adjoining (totally separate) texts in VS? I can do it in MS Word by selecting the texts separately by holding the Ctrl button, like this:

enter image description here

My version is 11.

Edit: I'm not talking about Alt+Select block selection. Also I would love to see if there exist a technique in Notepad++.

Visual Studio Solutions


Solution 1 - Visual Studio

Multi cursor edit is natively supported in Visual Studio starting from version 2017 Update 8. The following is an extract of the documentation:

  • 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

Some of those commands are also available in the Edit menu:

Multiple Carets Menu

Solution 2 - Visual Studio

There is a new extension for Visual Studio 2017 called SelectNextOccurrence which is free and open-source.

> This extension makes it possible to select next occurrences of a selected text for editing. > > Aims to replicate the Ctrl+D command of Sublime Text for faster coding.

Features:

  • Select next occurrence of current selection.
  • Skip occurrence
  • Undo occurrence
  • Add caret above/below
  • Use multiple carets to edit (Alt-click to add caret)

Visual Studio commands:

  • SelectNextOccurrence.SelectNextOccurrence is bound to Ctrl+D by default.
  • SelectNextOccurrence.SkipOccurrence is not bound by default. (Recommended Ctrl+K, Ctrl+D)
  • SelectNextOccurrence.UndoOccurrence is not bound by default. (Recommended Ctrl+U)
  • SelectNextOccurrence.AddCaretAbove is not bound by default. (Recommended Ctrl+Alt+Up)
  • SelectNextOccurrence.AddCaretBelow is not bound by default. (Recommended Ctrl+Alt+Down)

SelectNextOccurrence options

https://marketplace.visualstudio.com/items?itemName=thomaswelen.SelectNextOccurrence

https://github.com/2mas/SelectNextOccurrence

Solution 3 - Visual Studio

In the Visual Studio Shift+Alt+. / Shift+Alt+,

  • Shift+Alt+. - match caret;
  • Shift+Alt+, - remove previous caret;

Same function as on VSCode Ctrl+D.

Much more setting Tool - Options - Environment - keyboard. Next in the Show commands containing enter Edit..

Also, can use keyboard schema Visual Studio Code. Available for Visual Studio 2017

For conclusion, nice link Visual Studio All keyboard shortcuts

Solution 4 - Visual Studio

In Visual Studio 2019, you can put your caret on the right place and then press SHIFT ALT and . (dot). This will select the next occurrence.

Solution 5 - Visual Studio

MixEdit extension for Visual Studio allows you to do multiediting in the way you are describing. It supports multiple carets and multiple selections.

Solution 6 - Visual Studio

From Visual Studio 2017 Version 15.8, Ctrl + Alt + Click is now supposed to be a built-in way to manage multiple carets.

https://blogs.msdn.microsoft.com/visualstudio/2018/08/30/improving-your-productivity-in-the-visual-studio-editor/

Solution 7 - Visual Studio

Just to note,

MixEdit is not completely free.

> "This software is currently not licensed to any user and is running in > evaluation mode. MIXEDIT may be downloaded and evaluated for free, > however a license must be purchased for continued use."

Upon installation and use, a popup redirects to webpage - similar to SublimeText's unlicensed software pop-up message.

Solution 8 - Visual Studio

For Visual Studio Code

Got to this question because I was looking for a way to select multiple words with mouse click on VS Code, which should be achieved by using alt+click, but this keybinding wasn't working (I think it is something related to my OS, Ubuntu).

For anyone looking for something similar, try changing the key to ctrl+click.

Go to Selection > Switch to Ctrl+Click for Multi Cursor

Solution 9 - Visual Studio

I couldn't find anything built in, which is sad. There is this functionality in CodeRush though.

With Notepad++, this feature comes in built in. Just turn on multi-editing from

> Setting > Preferences > Editing > Multi-Editing Settings

But its not as intuitive as MS Word which lets you select two words by double clicking on them (after Ctrl of course).

Solution 10 - Visual Studio

Update: MixEdit extension now provides this ability.

MultiEdit extension for VS allows for something similar (doesn't support multiple selections as of this writing, just multiple carets)

Head over to Hanselman's for a quick animated gif of this in action: Simultaneous Editing for Visual Studio with the free MultiEdit extension

Solution 11 - Visual Studio

in visual 2019, Open Options to show all enter image description here

and multi select: keep Ctrl + Alt then click position you want or, keep Shift + Alt then click position to multi select multi line from start to end line clicked

Solution 12 - Visual Studio

There is supposedly a way to do it now with Ctrl + Alt + Click but I use this extension because it has a bunch of other nice features that I use: https://marketplace.visualstudio.com/items?itemName=thomaswelen.SelectNextOccurrence

Solution 13 - Visual Studio

I'm not sure if this is a available for earlier versions, but using Visual Studio 2022 Community Edition, there is the option to convert the keyboard setup to match Visual Studio Code.

Head into Tools > Options > Environment > Keyboard, then drop down the Apply the following additional keyboard mapping scheme: list and select Visual Studio Code.

Keyboard settings - Visual Studio 2022 Community

Note that this initialises the basic keyboard setup for VS Code, so any changes that you've made in your personal VS Code editor won't be included; you'll need to set these up yourself.

While this doesn't directly answer the OP's question, it does give a commonality between editors, and I do much prefer the VS Code keyboard setup (with tweaks) to the Visual Studio's.

Solution 14 - Visual Studio

Now the plugin is Multi Line tricks. The end and start buttons broke the selection.

Solution 15 - Visual Studio

For multi-select, you can use CTRL-SHIFT-L. You can click over the word and then press key combinations(CTRL-SHIFT-L) this will select all same types of words from the file(vs-code).

Recommended Multi Select Solutions

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionnawfalView Question on Stackoverflow
Solution 1 - Visual StudioGian MarcoView Answer on Stackoverflow
Solution 2 - Visual StudioDrew NoakesView Answer on Stackoverflow
Solution 3 - Visual StudioАрсений СавинView Answer on Stackoverflow
Solution 4 - Visual StudioTrausti ThorView Answer on Stackoverflow
Solution 5 - Visual Studiorobertojj89View Answer on Stackoverflow
Solution 6 - Visual StudioÉric BergeronView Answer on Stackoverflow
Solution 7 - Visual StudioSM23View Answer on Stackoverflow
Solution 8 - Visual StudiojpennaView Answer on Stackoverflow
Solution 9 - Visual StudionawfalView Answer on Stackoverflow
Solution 10 - Visual StudioMrchiefView Answer on Stackoverflow
Solution 11 - Visual StudioQuan Tran HaiView Answer on Stackoverflow
Solution 12 - Visual StudioBen RauziView Answer on Stackoverflow
Solution 13 - Visual StudioPaulView Answer on Stackoverflow
Solution 14 - Visual StudiofrancaView Answer on Stackoverflow
Solution 15 - Visual StudioRaman Raj VermaView Answer on Stackoverflow