SSMS Tip: Vertical Text Selection

Vertical text selection in SSMSOccasionally, I’ll stumble across one of those neat tricks that makes me ask myself, “Why didn’t I know about this years ago?”. This was one such discovery, and has been a huge time saver for me.

Vertical Text Selection in SSMS

Typically, selecting blocks of text is done in a left-to-right, top-to-bottom order. If you use your mouse to select a word on line 2, for example, you can drag the cursor down multiple lines, which will select everything – including line breaks and whitespace – all the way through the end of the selection. But did you know that you can select and edit text vertically in SQL Server Management Studio? In the same way you select from left to right, you can select fixed blocks (rather than the entire line) of code. By holding down the Alt key during text selection, you can limit the selection to only the region you specify rather than grabbing all of the text on every line.

As shown below, holding down the Alt key during selection allows me to pick only the text region I want.


Once selected, you can do most anything with that text block. You can enter some replacement text or simply delete that block of text. When you enter or remote text, it applies to every single line in that selection, which allows you to perform bulk tasks such as adding a COALESCE() statement to every column as shown below.


You can also copy and paste text selected in this way. Expanding the example from above, I want to use an alias for each coalesced column, so I can use the same method to vertically select and then vertically paste the code.


Just remember when you copy and paste like this, you have to vertically select the paste region just like you did with the copy.

I’ve found that this vertical text selection isn’t limited to just SSMS. If you are a Notepad++ user, you can do the same thing with that tool. Sadly, it doesn’t yet work in Visual Studio.

I hope you find this tip as useful as I have. This little trick has saved me a lot of manual typing over the years!

About the Author

Tim Mitchell
Tim Mitchell is a data architect and consultant who specializes in getting rid of data pain points. Need help with data warehousing, ETL, reporting, or training? If so, contact Tim for a no-obligation 30-minute chat.

1 Comment on "SSMS Tip: Vertical Text Selection"

  1. Thanks! You’ve saved me a lot of time!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.