Visual Studio 2010 Code Editor Box Selection and Multi-Line Editing
I had seen it before but now that Scott Guthrie ‘bragged’ about it I feel the need to respond.
Yes it is cool to be able to do box selection just because you can but:
- How many times do you actually need to change multiple variables from public to private?
- How many times do you need to change the names of variables due to a coding convention? (And will they all start in the same column?)
- How many times do you need to add the same comment to every line?
One of the best skills a programmer has to acquire is the DRY principle. Don’t Repeat Yourself. All I see is the danger of inexperienced people writing the same lines over and over again because now they able to do so very quickly thanks to Multi-Line Editing:
private int _number0 = 0;
private int _number1 = 1;
private int _number2 = 2;
private int _number3 = 3;
private int _number4 = 4;
private int _number5 = 5;
private int _number6 = 6;
private int _number7 = 7;
private int _number8 = 8;
private int _number9 = 9;
 
private void OhNoes()
{
Console.WriteLine(_number0);
Console.WriteLine(_number1);
Console.WriteLine(_number2);
Console.WriteLine(_number3);
Console.WriteLine(_number4);
Console.WriteLine(_number5);
Console.WriteLine(_number6);
Console.WriteLine(_number7);
Console.WriteLine(_number8);
Console.WriteLine(_number9);
}
Instead of:
private int[] _numbers = new []{0,1,2,3,4,5,6,7,8,9};
 
private void OhYes()
{
for (int i = 0; i < _numbers.Length; i++)
{
Console.WriteLine(_numbers[ i ]);
}
}
 
 
Two other issues I ran into while in Multi-Line Editing mode are:
- No code completion; no support for Ctrl+Space, Shift+Ctrl+Space and snippets (tab-tab).
- No renaming/refactoring; Ctrl+.
All in all: a nice feature so you can copy past a block from Visual Studio to your blog.