Saturday, February 17, 2007 4:30 PM bart

Visual Studio tip - select a rectangular block of code

A little tip but definitely a time-saver in case you didn't know about it yet... Quite a bit of Word users should be familiar with this one:

What I'm talking about is ALT+mouse selection (any official marketing name for this feature out there?). Guidelines: hold the ALT button on the keyboard and make a selection with the mouse; you'll be able to select a "rectangular block" of text. But did you know it's out there in Visual Studio too?

The reason for this post: recently a reader of my blog complained about the line numbering in my code samples:

1 using System; 2 using System.Collections.Generic; 3 using System.Text; 4 5 namespace RunspaceDemo 6 { 7 class Class1 8 { 9 public void Bar() 10 { 11 Console.WriteLine("Hi there"); 12 } 13 } 14 }

When copying this piece of code to Visual Studio, you'll see something like this:

Of course, you could manually delete all of the line numbers. However, using ALT+select this becomes much easier:

Just press Delete and you're ready to go!

Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Filed under:

Comments

# re: Visual Studio tip - select a rectangular block of code

Sunday, February 18, 2007 12:43 AM by timvw

I found out about that (and other tricks) in a nice, free e-book: http://www.infoq.com/minibooks/vsnettt

# re: Visual Studio tip - select a rectangular block of code

Sunday, February 18, 2007 4:25 AM by bart

Thanks for pointing us to this book, Tim!

# re: Visual Studio tip - select a rectangular block of code

Sunday, February 18, 2007 8:20 AM by Eric

Allright, cool tip ... didn't know this feature was in Visual Studio. Just tested it to be sure ... and it also works with Visual C# Express!