There are several different options available for working with tabs and spaces in SSMS. In fact, there are enough that I could make several tips out of them. I decided to just keep all the tips together.

Tabs and Spaces options

The first thing that I want to go over are the various option settings that are configurable in SSMS.

Regardless of whether you like to use tabs or spaces, this is where you go to configure your settings. The first part of the screen controls the indenting options. If “None” is selected, then the next line will start at the beginning of the line. If you have selected “Block”, then it will align the next line with the previous line. And if you are using “Smart”, then the appropriate language will determine which indenting style to use.

The next section controls the tab size / indent size. This controls how many characters that a tab takes. It also controls whether tabs are converted to spaces or kept as tabs.

You can read more about these options at this link: Manage Code Formatting.

Viewing White Space

Now that you have the options set to what you like to use, how do you find out what a file is using? Just select the “View White Space” option from the Edit | Advanced menu.

This option will convert this text in SSMS:

to this:

Now you can see that tabs were used everywhere, except for the line with the first column. That line has a mixture of tabs and spaces. Whether you want to use all tabs or all spaces, you have something to change.

Changing tabs to spaces, or spaces to tabs.

In the Edit | Advanced menu option (see above screen shot), the first two items will swap spaces to tabs (Tabify Selected Lines) or tabs to spaces (Untabify Selected Lines). Selecting these lines and choosing the “Tabify Selected Lines” option makes the code look like this:

Great, all the spaces have been converted to tabs. That is, unless I want to use all spaces. Then just select “Untabify Selected Lines”:

This post is for day thirty-four of my blog series “A Month of SSMS Tips” (Yes, I’ve gone beyond a month – there’s just so many things that SSMS can help you with!). I have a landing page for the series at Please visit this page for an easy place to quickly view all the other tips in this series.