Multiple select in Visual Studio?

2020-02-07 16:14发布

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++.

12条回答
放荡不羁爱自由
2楼-- · 2020-02-07 16:53

Multi cursor edit is natively supported in Visual Studio starting from version 2017 Update 8. Here is the documentation:

Multi-caret selection

and here is a screenshot of available command:

Multiple Carets Menu

查看更多
我欲成王,谁敢阻挡
3楼-- · 2020-02-07 16:53

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

查看更多
姐就是有狂的资本
4楼-- · 2020-02-07 16:55

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

查看更多
你好瞎i
5楼-- · 2020-02-07 16:55

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).

查看更多
我想做一个坏孩纸
6楼-- · 2020-02-07 16:57

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/

查看更多
Root(大扎)
7楼-- · 2020-02-07 16:57

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

查看更多
登录 后发表回答