-11

People have asked similar questions in the past: Auto-expand TAB character in code formatting is from September 2012

I haven't found a single post where someone used a tab character and intended for it to be anything other than 8 spaces. On the other hand, I've seen numerous edits where people have to correct the indentation because of how tabs are handled. Should tabs be treated as 8 spaces?

9
  • 13
    Well, when I code in my editor, I have it set to treat tabs as 4 spaces. So now you've encountered someone. Congratulations!
    – animuson StaffMod
    Oct 2, 2013 at 16:58
  • 1
    If you have something to add to an existing feature request (especially one that is not declined), you are best served at adding a bounty to the previous question to draw more attention to it, or provide your own answer to support the feature request Oct 2, 2013 at 16:58
  • 3
    Not everyone uses 8 spaces for TAB. It is quite common to have 4, I have seen 3 and other variations.
    – Oded
    Oct 2, 2013 at 17:00
  • @animuson read the statement's words: " a single post ". Do you post code where tabs are 4 characters?
    – SheetJS
    Oct 2, 2013 at 17:36
  • @Oded the set of people who use anything other than 8 characters for tab and who post code segments with tabs on SO is vanishingly small
    – SheetJS
    Oct 2, 2013 at 17:37
  • 6
    How did you determine this?
    – Oded
    Oct 2, 2013 at 17:45
  • 5
    @Nirk That doesn't make any sense. Most people don't intend for it to be any number of spaces, they intend for it to be an indentation. Aside from that, a tab does not equal eight spaces. A tab represents anywhere from one to eight (by default) spaces depending on where in the text it is placed, so "expand all tabs to eight spaces" is completely illogical. That's not what a tab means.
    – animuson StaffMod
    Oct 2, 2013 at 18:41
  • 2
    I've seen four, two, and used three. I don't think I've seen eight much at all. That assumes we should want tabs converted to spaces in the first place, which I disagree with anyway. Oct 2, 2013 at 19:02
  • I use 4 spaces for my C-style code and 2 spaces for XML-style code.
    – JDB
    Oct 2, 2013 at 19:31

1 Answer 1

4

I always use 4 or 2 spaces for tabs in my editors, but in regards to Stack Overflow I think 4 would work well since that is what is needed to tell markdown that you have a code block. I do think it'd be nice if they auto-converted the tabs to spaces, as per the question you linked to.

2
  • 4
    If I agreed with converting them, four would be the number I would choose, largely for the reason you mention. Oct 2, 2013 at 19:03
  • I’d rather we just set a proper tab-size.
    – Ry-
    Oct 2, 2013 at 19:43

Not the answer you're looking for? Browse other questions tagged .