Click here to Skip to main content
13,247,336 members (89,604 online)
Click here to Skip to main content
Add your own
alternative version

Stats

2.9K views
3 bookmarked
Posted 17 Jul 2017

Visual Studio Box Selection with Alt Key

, 18 Jul 2017
Rate this:
Please Sign up or sign in to vote.
This is an alternative for "VS2010 Box Selection with Copy and Paste"

This tip is just a reminder on the Box Selection — a cool feature which is available in Visual Studio, MS SQL Server Management Studio and... even in MS Word!

What is Box Selection?

Box Selection, or Multi-Line Editing, or Column Selection is the possibility to select a rectangular region of text with mouse or keyboard arrows. The Box Selection feature is being activated by pressing the Alt key on the keyboard.

To select a rectangular region of multiline text with a mouse:

  • press the Alt key
  • place a mouse pointer on text
  • holding the Alt key, press and hold the left mouse button
  • drag the mouse pointer over the diagonal to select a rectangular region
  • release the mouse button and the Alt key

The similiar selection result can be achieved with a keyboard:

  • place a text cursor on a start position in your text
  • press and hold the Alt key together with the Shift key
  • operate the keyboard arrow Right, Down, Up, Left to select the required rectangle
  • release the Alt key and the Shift key

The received rectangle selection can be copied and pasted, cut and replaced.

The Box Selection is very useful when it is necessary to work with table columns and object fields. For example, it is convenient to build a select statement just by copying the fields from a create table statement.

Even more! The habit of working with columns of text, cutting and pasting text with rectangular regions, will change the style of code writing.

For example, the following create table statement is not convenient for the Box Selection:

create table dbo.People
(
    Id int not null identity,
    Nickname nvarchar(50) not null null,
    Surname nvarchar(50) not null null,
    Forename nvarchar(50) not null null,
    Gender bit null,
    Birthday date null null,
    Phone varchar(20) not null,
    Email varchar(50) not null,
    Notes nvarchar(500) null
);

but this one is:

create table dbo.People
(
    Id          int             not null    identity,
    Nickname    nvarchar(50)    not null    ,
    Surname     nvarchar(50)    not null    ,
    Forename    nvarchar(50)    not null    ,
    Gender      bit                 null    ,
    Birthday    date                null    ,    
    Phone       varchar(20)     not null    ,
    Email       varchar(50)     not null    ,
    Notes       nvarchar(500)       null
);

And this Box-Selection-Ready or Alt-Style code is more readable and less error-risky than the first statement.

Show Me How!

Here is the animated example of the Box Selection in action:

Box Selection

The above GIF animation has been created with ScreenToGif program.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Vadim Loboda
Russian Federation Russian Federation
"It is best to erase all personal history, because that would make us free from the encumbering thoughts of other people."

Journey to Ixtlan by Carlos Castaneda

You may also be interested in...

Comments and Discussions

 
PraiseNice! Pin
Ravi Bhavnani17-Jul-17 8:35
professionalRavi Bhavnani17-Jul-17 8:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171114.1 | Last Updated 18 Jul 2017
Article Copyright 2017 by Vadim Loboda
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid