Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Tabs or Spaces


Tabs or Spaces

Author
Message
call.copse
call.copse
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2841 Visits: 1857
Tabs - you can post hoc indent or outdent blocks more easily.
Sean Smith-776614
Sean Smith-776614
SSC-Addicted
SSC-Addicted (427 reputation)SSC-Addicted (427 reputation)SSC-Addicted (427 reputation)SSC-Addicted (427 reputation)SSC-Addicted (427 reputation)SSC-Addicted (427 reputation)SSC-Addicted (427 reputation)SSC-Addicted (427 reputation)

Group: General Forum Members
Points: 427 Visits: 942
Tabs all the way.
Slyfin
Slyfin
SSC Rookie
SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)

Group: General Forum Members
Points: 35 Visits: 254
I agree with call.copse. Tabs all the way

Although I did learn the hard way not to tab after # and space in the powershell ISE(Autocomplete failed and the ISE crashed on me. Had to add the space since hitting tab after # doesn't do anything)
SanDroid
SanDroid
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1410 Visits: 1046
What makes this even worse is when you use universal source control.
The quickest way to mess up the spaces and tabs in our SQL source is when we extract it and check it into source control.
When you pull the SQL scripts back out of source control all the tabs and spacing are off. The code still works, but readability is terrible.
This is mostly caused by code that was written with Tabs set to 3 spaces instead of 5.
Lynn Pettis
Lynn Pettis
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24157 Visits: 37929
I have SSMS set to replace tabs with spaces. That way I use a tab to indent but it actually uses spaces.

If I need to change an indent on a block of code I simply highlight the block and use tab or shift tab depend on which direct it needs to go.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
CYates
CYates
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 184
I've been in both environments regarding standards. Personal preference wise I use spaces; however I think the nail was hit on the head of a standard being put into place. Whatever the standard becomes it should be follow depicting unity among team members.

I don't really know if there is a wrong or right answer to this one; it is one that has and probably will all ways be battled out!
roger.plowman
roger.plowman
SSChasing Mays
SSChasing Mays (608 reputation)SSChasing Mays (608 reputation)SSChasing Mays (608 reputation)SSChasing Mays (608 reputation)SSChasing Mays (608 reputation)SSChasing Mays (608 reputation)SSChasing Mays (608 reputation)SSChasing Mays (608 reputation)

Group: General Forum Members
Points: 608 Visits: 1119
Nakul Vachhrajani (3/18/2012)

I always insist that my team has the "replace tabs with spaces" switch in SSMS options checked and also run code through the "beautifer" option of "Untabify selection".

In my humble opinion, there should be a consistent set of coding aesthetic standards that should be enforced by default (and result in warnings) by Visual Studio and associated tools.


THANK YOU!

I have been looking for that setting forever. I thought SSMS lacked it. Then I went looking again because of your post.

For anyone else who couldn't find it, it's Tools / Options / Text Editor / Transact-SQL / Tabs

Then set your tab and indent size, and choose "Insert spaces". Me, I use tabs set to 3 spaces...
jfogel
jfogel
SSC-Addicted
SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)

Group: General Forum Members
Points: 445 Visits: 1148
Tabs

Cheers
honza.mf
honza.mf
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1767 Visits: 1323
Another point of view: Best setting is the default setting of the tool (SSMS, VS, ...). Otherwise you have inconsistencies by everyone who has forgotten to change the setting.
And some people reinstall very often.



See, understand, learn, try, use efficient
© Dr.Plch
Mike Dougherty-384281
Mike Dougherty-384281
Old Hand
Old Hand (314 reputation)Old Hand (314 reputation)Old Hand (314 reputation)Old Hand (314 reputation)Old Hand (314 reputation)Old Hand (314 reputation)Old Hand (314 reputation)Old Hand (314 reputation)

Group: General Forum Members
Points: 314 Visits: 944
tabs

To borrow from web design: semantic meaning. If the tab character (following newline) is taken to mean "indent" then four levels of indentation is literally 4 tab characters. I use tab to align the '=' following a field alias. In this usage it means align the equal sign to some visual column for the purpose of readability. It would be great to have the IDE understand this convention and implement it without requiring me to use multiple tab keystrokes to compensate for longer/shorter field aliases.

I feel that a space should be reserved to mean a literal space character.

I also agree that it's largely a non-issue when beautifiers can reformat valid code into any visual presentation you want. In that case the code is actually reparsed and any original whitespace is irrelevant.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search