Box Selection in Visual Studio

This is one of those “in case you didn’t know” posts.

Edit Multiple Lines At Once

Visual Studio lets you create a box selection by holding the ALT key and dragging your mouse to select a rectangular area of text. Why is this useful? Take this sample code:

public HyperLink hlNavHeaderHome;
public HyperLink hlNavHeaderArticles;
public HyperLink hlNavHeaderBlog;
public HyperLink hlNavHeaderShop;
public HyperLink hlNavHeaderAbout;
public HyperLink hlNavHeaderContact;
public HyperLink hlNavHeaderAdvertising;

Those variable names are kind of long, so say you want to shorten them by taking the “NavHeader” part out of each one. You can use a box selection to select “NavHeader” across all 7 rows at once, then hit DELETE and be done.

You can also create a multi-line caret by holding ALT and dragging your mouse straight down across multiple rows. Then when you start typing, your text will appear on multiple lines simultaneously.

Demo

Watch the demo by Brittany Behrens to see it in action:

Hey, you reached the end!

Feel free to check out my other blog posts or subscribe to my RSS feed. You can also click a tag below to see related blog posts.