Visual studio tip 1 : How to select code in a rectangular fashion?

By Shivprasad Koirala

When we select source code in visual studio it selects the complete source code , but what if we want to select the code in a rectangular manner?

When we select source code in visual studio it selects the complete source code as shown below.

public class Customer
    {
        private int CustomerCode;
        private string CustomerName;
        private string Address;
        private string PhoneNumber;
        private bool IsGold;
        private short PostalCode;
        private int FileNumber;
        private string PenName;
        private string AlterNateAddress;
        private string PagerNumber;
        private bool IsActive;

    }


But what if we want to select partial code in a rectangular fashion as shown in the below figure.

As you select probably you would also like to modify that selected portion code as shown in the below figure.


To do a rectangular selection press your ALT button of the keyboard as you select the code using the left button of your mouse. Once the code is selected start your modification as pre your wish.



Video for the Tip above: - http://www.youtube.com/watch?v=D5eLVAmBWIE

Related FAQs

Many times as a developer you come across functions with lots of input parameters as shown in the below code snippets. In real projects the input parameters would be much higher as compared to the below code snippets. Some times for various reasons you want to shuffle them, reorder them or remove some of them.
In big project you have 100’s of classes and each of those classes can have lots of properties.
In this section we will see a very interesting and useful trick of visual studio called the extract method.
Now many times as a .NET developer we need connection strings to connect to databases. Connection string are long and cryptic and very difficult to remember. In this tip we will see a easy way of getting connection strings.
Many times we write comments in code to remind about certain tasks to be performed later and then we forget about the same as the comments gets lost in those million lines code.
Many times due to project pressure and lazy attitude you violate encapsulation and create public variables for classes as shown below. Even though your inner heart knows that the best practice is to create set and get property function but your lazy attitude overrules it.
Visual studio tip 1 : How to select code in a rectangular fashion?  (645 Views)
Create New Account