Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Visual-Studio

Box Editing with VS2010 - Editing multiple lines at once

4.67/5 (3 votes)
27 Apr 2010CPOL 1  
Visual Studio 2010 provides a feature by which it is now possible to edit multiple lines at one go.For e.g. say you have a class which you have three member variables which are declared as private.public class MyClass{ private int myInt; private double myDouble; private...
Visual Studio 2010 provides a feature by which it is now possible to edit multiple lines at one go.

For e.g. say you have a class which you have three member variables which are declared as private.

public class MyClass
{
   private int myInt;
   private double myDouble;
   private string myString;

   ...
}


Now if you want to change the access of these member variables from private to protected, in VS2008 and before you need to select each private word and change it to protected.

In Visual Studio 2010, there is a better alternative to that.

Just press Alt key and perform a vertical selection and select all the three private words. (If you are using the keyboard only, then use the keys Shift + Alt + Arrow keys to select the words.)

Now just type protected once and you will notice that protected is being typed in all the three lines together. Saves a lot of time! :)

C#
public class MyClass
{
   protected int myInt;
   protected double myDouble;
   protected string myString;
   ...
}


Alternatively, you can copy the protected word first and then perform a vertical selection (using Alt key) of all the three private words and paste once. It will paste in all three lines.

Check these links for further reference:

Link 1[^]
Link 2[^]

License

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