The support of multi-selection for Visual Studio by CodeRush
The Visual Studio IDE has a great box selection feature that allows you to select a rectangular region of text within the code editor by holding down the Alt key while selecting the text region with the mouse:
However, the selected region should represent a single continuous selection box. In other words, you can not select multiple parts of the source code. But with the help of the CodeRush Multi-Select feature you can do that easily. This feature allows you to create multiple selections in the source code or a typical text in the active text document as follows:
You can cut, copy, paste or simply delete the multi-selected text in a single action via default shortcuts (Ctrl+C, Ctrl+X, Ctrl+V). Text selections are contained within the Multi-Select stack. You can have any number of stacks for each opened text document in the IDE.
Furthermore, the Multi-Select feature provides an additional action called Integrated Paste. It becomes available in the right-click code editor context menu if you have copied several members of a class into Clipboard:
The integrated paste inserts copied members in a specific order: methods to method, properties to properties, fields to fields etc. In other words, when you paste fields and properties, the copied fields will be moved near existing fields and new properties will be pasted right over other properties of the destination class. This feature might be very useful to rearrange members of a class when moving them to a different class.
The main purpose of the Multi-Select feature is to simplify source code edits. Consider the following code:
This class contains many properties. We can refactor this code by creating separate classes for the specific data. Let’s select the required properties and cut them:
then, paste them into a separate class:
And apply the same technique to other data, so we end up with this:
The original code will look like this:
This code is now much easier to read and understand.
The following Multi-Select shortcuts are available by default:
|Ctrl+Alt+Enter||MultiSelectAdd||Adds the current selection into the Multi-Select stack. If there is no selection, the current language element will be automatically selected.|
|Ctrl+Alt+Backspace||MultiSelectClear||Clears the current stack.|
|Ctrl+Alt+Num-||MultiSelectUndo||Removes the previous added selection from the stack.|
|Ctrl+Alt+Num+||MultiSelectRedo||The opposite of the MultiSelectUndo to restore the removed selection.|
Note that if you don’t have an active text selection, the Multi-Select feature will automatically expand the selection the same way as you would execute the Selection Increase command.
The Multi-Select feature is available out of the box. It was created as an open source plug-in in two CodeRush Feature Workshop webinars:
You can see how it was built from scratch and learn more on how to create CodeRush plug-ins.
The feature has a single option page (Editor | Selections | MultiSelect) in the Options Dialog that allows you to tweak the default highlighting color of a multi-selection piece.
You can also extend this feature programmatically via the DXCore MultiSelect service.—– Products: CodeRush Pro Versions: 12.1 and up VS IDEs: 2008 and up Updated: Aug/03/2012 ID: C170