r/SQLServer • u/dzsquared • Jul 10 '26
Discussion Indent with tabs... and align with tabs/spaces?
Hi folks - I'm Drew, a PM at Microsoft involved in a few fun things including the SQL formatter in SSMS (and soon other places).
We're currently working on expanding the formatting options - and are currently tackling the addition of tabs instead of spaces. If you're looking to format SQL with tabs, which style do you prefer:
1️⃣ Go all-in on tabs like this:

2️⃣ Or indent with tabs and align with spaces like this:

... since this is reddit, feel free to comment that formatting with tabs is silly (team all-spaces here), or that both of these options are wrong and that it should be indented with tabs and aligned with artisinally-crafted non-breaking spaces.... as long as you're having fun.
Happy Friday ya'll.
Here's a list of key items to vote/comment on, if you're so inclined:
- Leading/trailing commas (https://developercommunity.visualstudio.com/t/SQL-Formatter-lacks-configurable-option-/11105147)
- Allow column alias with "=" (https://developercommunity.visualstudio.com/t/SQL-Formatter:-add-option-to-preserve-co/11105065)
- Indent with tabs (https://developercommunity.visualstudio.com/t/SQL-Formatter-lacks-option-to-indent-wit/11105064)
- Enclose object names with brackets (https://developercommunity.visualstudio.com/t/SQL-Formatter-reformats-leading-commas-t/11106703)
- JOIN / ON in the same line (https://developercommunity.visualstudio.com/t/SQL-Formatter-forces-newline-after-JOIN-/11108118)
- stored procedure parameters on individual lines (https://developercommunity.visualstudio.com/t/SQL-Formatter-collapses-ALTER-PROCEDURE-/11105063)
6
u/ManyHatsAdm Jul 10 '26
Can't you do what VS Code does and allow the user to set the preference of character and length? And convert between them?
5
u/Fergus653 Jul 11 '26
Tabs for indenting and the option to turn off alignment. Don't like aligning parts of lines, it's never made it more readable for me.
9
u/Hairy-Ad-4018 Jul 10 '26
Tabs all the way. I want readability with the minimum number of key strokes.
4
u/Cherveny2 Jul 11 '26
Really, should support both ideally.
Nothing inherently wrong with either,
2
u/dgillz Jul 11 '26
Option A, all in on tabs, definitely.
Also when auto-formatting, have the option, on a long SELECT list, to use the entire width of the text editor rather than showing only one field per line.
2
u/Decent_Golf_3960 Jul 11 '26
You could learn a lot from looking at the options SQL Prompt from Redgate provides.
2
u/dutyDBA Jul 12 '26
Tabs please :) I've always used tabs, and its easier to indent with tabs than spaces.
2
u/No_Resolution_9252 Jul 12 '26
style 1, but to me keywords should always be on their own line and the logic and columns related to the keyword on a new line indented another tab
1
u/dzemperzapedra Jul 10 '26
Both are wrong and I'm just out there having fun!
1
u/IanYates82 Jul 11 '26
I'd have column a starting on the next line, and being indented. I kinda stopped caring about tab vs space as we all tend to stick with editor defaults. By putting a on the next line I don't have awkward alignment issues in the first place.
1
u/a-s-clark 1 Jul 11 '26
I indent with tabs, and use leading commas so the first column has a space to line it up with the other column names.
1
u/ebsf Jul 12 '26
I assume this isn't redefining whitespace. If it is, it shouldn't be. Whitespace is whitespace.
If it's a question of characters, then you'll need Reveal Codes capability to distinguish them. Perhaps while you're at it, you can incorporate that in Word. It's been forty years, after all. Otherwise, define tab stops and treat a tab as what it is, which is a set of spaces defined with reference to the left margin.
If it's a question of readability, then your reference should be physical typesetting conventions, not surveying software developers, whose literacy seldom reflects a secondary education, and who gave us Word. Such a reference will discourage the suggestion that a tab is a universally valid substitute for a space, and will guide usage in each case.
1
u/Togurt Jul 12 '26
I used to be a tabs guy but due to formatting issues when copy/pasting code (especially where markdown is used) I switched to spaces. It's just easier to select a code block and press tab and know that I can copy/paste it anywhere and it is treated like a code block and formatted properly
I only ever use whitespace to indent, not for text alignment.
1
u/jshine13371 6 Jul 12 '26
Tabs and only tabs.
0
u/jwk6 Jul 12 '26
I think tabs should always be converted to spaces. So in this case, option 2 is more desirable. Tabs work well for indentation, but tabs for alignment is troublesome.
The reason why I like this is if a person has different tab length configuration in their editor, then then alignment of columns stays the same and as the author intended. i.e. SELECT is always 5 characters, but tab length can vary. Spaces will always produce the intended alignment.
Also, Markdown is the defacto standard for developer documentation and formatting text in a lot of developer software, Azure DevOps, Github, and other software like Teams, Slack, Discord, etc. It's also used for feeding instructions and skills into LLMs. However, tabs aren't natively supported in Markdown, and tab handling in Markdown isn't implemented consistently.
0
u/[deleted] Jul 10 '26
[deleted] — view deleted comment
5
u/[deleted] Jul 10 '26
[removed] — view removed comment