This is me blogging the experience of programming at the speed of me. I work mostly on web apps and Windows Phone 7 and enjoy writing about the ups and downs of development in those spaces. I program on the .NET stack, am lovin' Windows 7 and Visual Studio 2010. Truth be told, the only ones that call me 'Mister James' are the three- and four-year-olds at Sunday school. But I'll take what I can get...

Pages

This blog has, IMO, some great resources. Unfortunately, some of those resources are becoming less relevant. I'm still blogging, learning tech and helping others...please find me at my new home on http://www.jameschambers.com/.

Wednesday, October 28, 2009

Badass Box Selection

Brittany Behrens on Monday re-introduced the much-improved version of Box Selection that came out with the Visual Studio 2010 Beta 2 bits. I was stoked about this earlier in the year.

I’m continually surprised when I see how many of my friends aren’t aware of so many of the time-saving tools that exist inside Visual Studio. It feels more and more like you can “run” when you code and less and less like you have to push through it.

I found a neat little compound trick using a couple of the features that I routinely exploit. Starting from essentially the same place as Brittany, I copied and pasted a list of variables into some multiline Console.WriteLine statements. That was pretty cool. Like Brittany, I was left with a series of semi-colons that I wanted to remove.

To get rid of the punctuation, I simply redo the box selection and then invoke the Find and Replace dialog with Ctrl-H:

From there, I can employ a simple matching technique and scrub the semi-colons. Just make sure you have Look in: Selection selected and hit Replace All.

If it were a more complex scenario, I could have also used regular expressions in Find and Replace (located in “Find Options”) to be more discerning on the text I was replacing.

I Like Pushing Arrows

There is something else in here of a hidden gem that wasn’t fully revealed in the video but that I picked up on (I heard Brittany tapping on the keyboard and had to try it out): using the cursor keys while holding down Shift allows you to “walk the box” and change the shape of the selection.

After using Alt+Mouse or Shift+Alt+Arrows to box-select, use Shift+Arrows to alter the target of the selection.

Let me Choose!

One thing that I liked in the video was that the white space was copied as well. This left the pasted text block-aligned and ready to go. The video obviously pre-dates the version of box selection in Beta 2, however, because as you can see from my above image, there is no whitespace after my variable names (watch the video to see the difference).

I think it would be good to have some optional, intermediary dialog box that you could call up (perhaps a la Office-Ctrl tapping) that would allow you to preserve or remove whitespace, punctuation, etc.

I suspect that the visibility of the selection is made available to any plug-ins, but I also hope there is something by way of box selection events so that context menus can leverage this. Not having worked with the extensibility bits around selection in the editor, I’m not sure if you can distinguish between box selection and stream selection when creating something to extend the IDE.

Certifications

A Bit About Me

From a technical perspective, I am a .Net developer, devoted to keeping up with new areas of learning. I try to grow in this regard through continued education, access to literature and time devoted to mentoring others -- a great way to learn. Most recently I have worked in the areas of development around ASP.NET MVC, Windows Phone 7, Windows Azure and the likes. I am a little too crazy about Linq (check out my Linq statement to convert IP addresses to decimals for proof). I lead our local .Net User Group and enjoy speaking publicly and the opportunity to teach to a large group of people. Personally, I am someone who believes in giving back to the community and my family is blessed to be able to give many hours to local and national charities, community organizations and to our church.