Click here to Skip to main content
Click here to Skip to main content

Tagged as

VS2010 Box Selection with Copy and Paste

, 17 May 2010
Rate this:
Please Sign up or sign in to vote.
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 StringBuilder.
 
Peter
Paul
Mary
Susan
Joe
...
Jacob
 
Here's how you can do it with box selection:
 
  1. In the method where you wish to build the list, type sb.AppendLine(""); where sb is the name of your StringBuilder object.
  2. Quickly copy & paste this line 20 times to set up a receiving area for the names.
  3. Open the text file of names in Visual Studio.
  4. 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).
  5. Copy the selection to the clipboard.
  6. 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.
  7. Paste your selection.
 
Voila! All names are pasted between the quotes, one per line without wrecking the code block! Here's a quick example of what it might look like when you're done:
 

 

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 <li> tags in an ASPX page.
 
Cheers!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

TheyCallMeMrJames
Software Developer (Senior)
Canada Canada
For almost 30 years I have been working with computers, learning a myriad of languages and participating in various computing environments.
 
Though I have been mentoring other developers for the last decade, I have recently found a strong interest in writing and am learning to translate the fun of in-person teaching to something I can get into article form.
 
I enjoy following technology trends, new gadgets and trying to guess where innovation will lead us next (I'm kinda holding out for a robot-served utopia, but willing to submit to our future robot leaders).
 
I am a guy who is passionate about my faith, my family and a cure for Juvenile Diabetes (my son lives with this disease).

Comments and Discussions

 
GeneralTo the -1 votes (on Muhammad and myself) PinmemberTheyCallMeMrJames18-May-10 2:55 
For those who are voting -1 on tips (or here, on Muhammad's comment) you really should have the cooyas to post why. For those of us that are contributing (instead of down-voting), it's hard for us to improve our tips/tricks/comments if you don't leave a note on how we can improve.
 
Thanks to Muhammad here for the comment, the alternate suggestion on the tip and the positive tone!

GeneralRe: To the -1 votes (on Muhammad and myself) PinmemberMuhammad Gouda19-May-10 6:58 
GeneralCongratulations PinmemberMuhammad Gouda17-May-10 12:14 
GeneralRe: Congratulations PinmemberTheyCallMeMrJames18-May-10 2:51 
GeneralVery handy tip! PinmemberDaveX8617-May-10 10:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 17 May 2010
Article Copyright 2010 by TheyCallMeMrJames
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid