Blog Post

Block Select/Replace (Day 11)

,

While Regular Expressions lets us work with text not cleanly formatted, if you are trying to work with text that lines up, there is an easier way to do things. Starting with SSMS 2012, you can use Block Select/Replace (note that this is actually a Windows feature, so it works in other programs that handle it).

There are two ways to activate this feature – by the mouse, or by the keyboard. Well, the mouse is a mouse/keyboard combination. To use the mouse, hold down the ALT key on the keyboard, and then using the left-click on the mouse, click and drag to select the desired block. To use the keyboard, position the cursor at the desired location, hold down the ALT + SHIFT keys, and then use the arrow keys to select the desired text. It will look something like this:

Now you can do something with all of the selected text. For instance, I could upper-case all of the highlighted words:

Alternatively, you can just type something, and it will appear at the insertion point on all of the lines. In the following screen shot, I have forgotten to use the “@” for the start of the variables:

Using the mouse, I highlight the block immediately prior the the variable names. Note that there is a very light vertical blue line just before the start of the variable names. Now I just type the missing “@”, and it is placed on all three lines:

When you have your block of text selected, you can perform other operations on it. For example, finding text just within that selected block.

This post is for day eleven of my month-long blog series “A Month of SSMS Tips”. I have a landing page for the series at bit.ly/MonthOfSSMS. Please visit this page for an easy place to quickly view all of the other tips in this series.

The post Block Select/Replace (Day 11) appeared first on Wayne Sheffield.

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating