SSMS Tips and Tricks 3-8: Selecting and modifying rectangular regions

I often see people doing very repetitive editing tasks that could easily be carried out by using selecting and changing rectangular regions of code.
The simplest example of doing this is to insert some text on a number of rows. Take the following code as an example:
I’ve got the skeleton of a list of columns in a CREATE TABLE statement but let’s assume that I’m a comma in front person and want to put a few spaces and a comma, etc. in front of each column after the second.
There are several ways to do this:
I could just put the cursor on the InvoiceID line and type what I wanted, then do the same again on the next line, and so on. That’s tiring.
Another option would be to do it on the first line, then select and copy it, and insert it into the front of every other line.
What I should do, however, is to put the cursor in front of InvoiceID, and while holding Alt-shift, use the down arrow to select the beginning of every line, then just type what I want.
Similarly, if I want to change text on a bunch of lines, I can do the same by using both down arrow and side arrow to select a rectangular region, then just type to replace. In this example, I have a table name that I want to change from InvoiceLines to OrderLines:
So I select the starting point, Alt-shift and arrows to select the rectangle, then just type:
If you weren’t aware of this, I hope you find it useful.
2025-07-12