Freigeben über


How to select and edit multiple columns in Visual Studio 2008 [Video]

When I was at university, my editor of choice was Emacs, primarily because it was very keyboard friendly and I could pretty much do everything with a few key strokes. Once you got used to the modifier keys, editing and navigation in Emacs was effortless.

One of my favorite features in Emacs is the ability to edit multiple columns at a time. There are many scenarios where being able to edit multiple columns at the same time can come in handy. Let's look at a couple of examples. In the first example, I want to format the multi-dimensional array "matrix" to look like the one specified in the comments.

 static void Main()
{
    // Example 1: Formatting a multi-dimensional array

    int[,] matrix = new int[,]
        { 
        { 1, 0, 0 },
        { 0, 1, 0 },
        { 0, 0, 1 }
        };


   /** The array declaration above should look like this:
          
    int[,] matrix = new int[,] { { 1, 0, 0 },
                                 { 0, 1, 0 },
                                 { 0, 0, 1 }
                               };
     **/
}

In the second example, I want to remove all the comments from the following code:

 // Example 2: Remove comments from the following code.

/*
 * [assembly: DebuggerDisplay(@"\{InnerText = {InnerText}}", Target = typeof(HTMLControls::HtmlGenericControl))]
 * [assembly: DebuggerDisplay(@"\{Value = {Value}}", Target = typeof(HTMLControls::HtmlTextArea))]
 * [assembly: DebuggerDisplay(@"\{Value = {Value}}", Target = typeof(HTMLControls::HtmlInputText))]
 * [assembly: DebuggerDisplay(@"\{Value = {Value} Checked = {Checked}}", Target = typeof(HTMLControls::HtmlInputCheckBox))]
 * [assembly: DebuggerDisplay(@"\{Value = {Value} Checked = {Checked}}", Target = typeof(HTMLControls::HtmlInputRadioButton))]
 */

Watch the following video to see how ALT+SHIFT+ARROW KEYS make column selection and editing easy.

Habib Heydarian.

Comments