可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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:
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++.
回答1:
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:
回答2:
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)
https://marketplace.visualstudio.com/items?itemName=thomaswelen.SelectNextOccurrence
https://github.com/2mas/SelectNextOccurrence
回答3:
MixEdit extension for Visual Studio allows you to do multiediting in the way you are describing. It supports multiple carets and multiple selections.
回答4:
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/
回答5:
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
回答6:
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.
回答7:
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
回答8:
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
回答9:
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).
回答10:
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
回答11:
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.
回答12:
Now the plugin is Multi Line tricks. The end and start buttons broke the selection.