

Hold down the SHIFT+ALT keys and press any Arrow key. Hold down the ALT key, press down on the left-click button of your mouse, and then drag the cursor over the text to select.

Wasn't there a keyboard short cut in an old visual studio that would enable/disable that kind od selection? Re: Copying and pasting rectangular blocks of code in Visual Studio and Management Studio Pretty nifty! Thanks, Ellen, for the tip!īy the way, this technique works in the SQL Server Management Studio editor, too. By copying the block you can quickly and easily paste only the relevant text (the variable names) into the procedure like so.

At a later point in your coding, you need to set the value of all of these variable. Why is this useful? Consider declaring a bunch of variables as show above. Then you can use normal techniques to copy the text and paste it wherever you'd like.

Pressing the Alt key tells the editor not to select the entire line, but to follow the mouse pointer wherever it goes. You can depress the Alt key while using the left mouse button to select rectangular areas of code. One of my students showed me an old Microsoft Word trick. I would have thought that Microsoft would have put that in Visual Studio. Other editors that I've used over the years - emacs, vim, Notepad++, UltraEdit - can do that. In a custom Visual Studio/SQL Server class last week, I made a passing comment about Visual Studio being a very good text editor, but that it lacked one feature that I really like in other editors - block copy and paste. I lamented that the Visual Studio editor doesn't allow you to select a rectangular area of code and then copy and paste it elsewhere in the document. So, it works out well for both student and instructor. Frequently, I can learn from their experiences, too. One of the things I really like about teaching technical classes is getting to know and talk with students, learning of the challenges they face and how they've addressed them. Copying and pasting rectangular blocks of code in Visual Studio and Management Studio
