VS2010 Box Selection with Copy and Paste






3.92/5 (11 votes)
With the new box selection model in Visual Studio 2010 you can do some crazy new things, the coolest for me being the copy and paste support from and to selections.As a simple example, let's assume you have a text document with a list of 20 names that you want added to a...
With the new box selection model in Visual Studio 2010 you can do some crazy new things, the coolest for me being the copy and paste support from and to selections.
As a simple example, let's assume you have a text document with a list of 20 names that you want added to a
What's cool about this is that in a single copy-paste operation you can inject lines of content (or code). The box selection takes care of ignoring the whitespace!
This trick also works in other editors, such as pasting into a set of empty
StringBuilder
.
Peter Paul Mary Susan Joe ... JacobHere's how you can do it with box selection:
- In the method where you wish to build the list, type
sb.AppendLine("");
wheresb
is the name of yourStringBuilder
object. - Quickly copy & paste this line 20 times to set up a receiving area for the names.
- Open the text file of names in Visual Studio.
- Rather than line-selecting the names, box select them with the mouse while holding the ALT key (it's okay if you capture whitespace when the names are longer than others).
- Copy the selection to the clipboard.
- Return to your method. Vertically box-select the space between the quotes, again by using the mouse to select while holding the ALT key. You get a thin line for a selection that is zero characters wide.
- Paste your selection.

<li>
tags in an ASPX page.
Cheers!