Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘selection’

Box Selection with Visual Studio 2010

Box selection is a feature that has been in Visual Studio for awhile (although not many people knew about it).  It allows you to select a rectangular region of text within the code editor by holding down the Alt key while selecting the text region with the mouse.  With VS 2008 you could then copy or delete the selected text.

VS 2010 now enables several more capabilities with box selection including:

  • Text Insertion: Typing with box selection now allows you to insert new text into every selected line
  • Paste/Replace: You can now paste the contents of one box selection into another and have the content flow correctly
  • Zero-Length Boxes: You can now make a vertical selection zero characters wide to create a multi-line insert point for new or copied text

These capabilities can be very useful in a variety of scenarios.  Some example scenarios: change access modifiers (private->public), adding comments to multiple lines, setting fields, or grouping multiple statements together.

A cool Visual Studio 2010 feature

Keyboard Shortcut Tricks in Visual Studio 2010

  1. visual-studio-2010-asp.net4 Insert a blank line above or below the current line:
    Go to any line in the Editor and press CTRL + Enter to insert a line above or CTRL + SHIFT + Enter to insert a line below the current line.
  2. Pasting a single selection into a box selection
    ALT + Left Mouse
  3. Zoom in or out of text in the Editor using the mouse wheel
    CTRL + Mouse Wheel
  4. Zero-length box selection
    Alt + Left Mouse
    • Assume that you have a a situation with some variables like the ones below and you want to make them all public
    • The answer is a zero-length box selection.  Hold down your ALT key and Left Mouse Button, then drag straight down
    • Release the ALT key and the Left Mouse Button.
    • Done~