Pasting a single selection into a box selection

Tips Search

If you like the tips then you'll love the book!

Order your copy today:
http://www.amazon.com/gp/product/0735649928

Pasting a single selection into a box selection

  • Comments 3

Keyboard:  ALT + Left Mouse
Versions:  2010
Published:  1/13/2010
Code:  vstipEdit0008

 

In a previous tip, we looked at pasting one box selection into another.  In this tip we will see how to take a single selection and put it into a box selection.

Let's assume you have a setup like this:

image

 

But you realize that you need change int to double.  No problem!

Select the double keyword and copy it (CTRL + C):

image

 

Then box select the destination (ALT + Left Mouse):

image

 

Finally, do a paste (CTRL + V) to see the result:

image

 

I've used this one a lot since I first heard of it and it totally rocks!

  • This doesn't work in my version of VS 2008. It will only replace the first instance of int.

  • Good tip!  I designed the improvements to box selection for VS 2010, so it's great to see box selection tips & tricks being shared :-)

    For the curious, there are two other ways to accomplish the task shown in this tip:

    1.)  [VS 2008 and VS 2010] Make a box selection (in this case a standard selection would also work) around the entire area shown in the screenshot.  Press Ctrl+H to bring up Quick Replace; "Look in: Selection" should be preselected automatically.  Replace "int" with "double" in your selection, and you're done.

    2.)  [New for VS 2010]  Make the box selection shown around the three "int"s.  Now type "double."  The text will be inserted on all three lines simultaneously, eliminating the need to copy and paste at all :-)

    @AboutDev:  You're right that this doesn't work in VS 2008, but it does in VS 2010.  We've revamped Box Selection for VS 2010 and added a good bit of new functionality.

    For details and a demo video of what's new for box selection in VS 2010, check out this post on the Visual Studio blog:  http://blogs.msdn.com/visualstudio/archive/2009/10/26/box-selection-and-multi-line-editing.aspx

    Brittany Behrens

    Program Manager, VS Platform - Editor

  • AboutDev :)

    These tips are for Visual Studio 2010 in this series so some of the tips will work with older versions of VS and some won't.  I don't make the distinction on the blog as they all work with VS2010 when I test them.

    I am considering doing a book that goes back to VS2005 and, if I decide to crank it out, it will have version information.

    Z

Page 1 of 1 (3 items)
Leave a Comment
  • Please add 8 and 5 and type the answer here:
  • Post