• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Indenting in code - Tabs or Spaces?

Tabs or Spaces

  • Tabs

    Votes: 58 60.4%
  • Spaces

    Votes: 38 39.6%

  • Total voters
    96
Ok, I guess I assumed it worked in a different way. I thought that when it converted it to spaces, the \t no longer existed and only spaces were left...

No, you wouldn't. If the \t character is in the file, the editor displays its version of \t. If 2, 3, or 4 spaces are in the file, it displays 2, 3, or 4 spaces. If everyone puts a tab in, everything lines up on their screen (probably, spacing beyond the first tab may be screwy if they use spaces there) If people put X spaces in, but X changes between people in one file, stuff doesn't line up anymore.

I still prefer spaces, but I work in console editors sometimes, so I like to restrict it to 80 chars, and I'm the only one working on my code (student) so yeah. Plus, it's the coding standard for my school.

How is it a problem if their editor displays the tab how they like to see the code? :confused:
 
It'd be nice if there was a css property for this.

example use:
Code:
textarea.code, pre.code {
    tab-display-width: 4sp; /* and other units */
}
 
Tabs all the way. Revising indent structures with spaces? Messy. I won't stand for it.
 
Tabs are 80% more efficient in typing if they represent 5 spaces as a single \t.

I expected more tab fans rather than spaces or even soft tabs.
 
I should use soft tabs, but I don't. Most coding standards specify 4 spaces for indentation. But, I've just gotten used to it, so for me, using tabs is perfectly acceptable to indent code. However, the issue with using tabs is demonstrated in the following piece of code:

Code:
var bagel = new Array('cream cheese',
                      'honey',
                      'sesame',
                      'toasted');

If that line had been indented, you'd need to use a mixture of tabs + spaces to align that code. If you use tabs alone, you will not be able to align it properly.

I have no idea why anyone would code in a variable width font, though. None of the characters would line up.
 
I should use soft tabs, but I don't. Most coding standards specify 4 spaces for indentation. But, I've just gotten used to it, so for me, using tabs is perfectly acceptable to indent code. However, the issue with using tabs is demonstrated in the following piece of code:

Code:
var bagel = new Array('cream cheese',
                      'honey',
                      'sesame',
                      'toasted');

If that line had been indented, you'd need to use a mixture of tabs + spaces to align that code. If you use tabs alone, you will not be able to align it properly.

I have no idea why anyone would code in a variable width font, though. None of the characters would line up.


This code layout problem is solved by using tabs ONLY for indenting, not lining up code.
 
Soft tabs. Does that technically count for spaces or tabs in the poll? I think I hastily and incorrectly picked spaces.

Code:
var bagel = new Array('cream cheese',
                      'honey',
                      'sesame',
                      'toasted');

Now I gotta go toast a bagel with some cream cheese. Thanks for the inspiration. Cinnamon cream cheese is delicious.
 
Soft tabs. Does that technically count for spaces or tabs in the poll? I think I hastily and incorrectly picked spaces.

spaces, the actual key you press doesnt really have direct consequence when it comes to other people reading your code. it's the actual encoding that counts

this of it as:

"\t vs. space characters for indents?"

i think the poll is pretty much useless at this point do to this apparent misinterpretation

bagels and cream cheese ftw
 
The only person who can answer a question like that is the one who signs your timesheet or paycheck.
 
Another thing I just realized about spaces vs tabs...

Spaces make the file size quite larger. I was trying to compare two documents, one was converted to tabs and so every line was showing up in the diff. So I swapped my other copy which was tabs and the file size went from 63k -> 79k. This is on a 2170 line file :p
 
think of it as:

"\t vs. space characters for indents?"

i think the poll is pretty much useless at this point do to this apparent misinterpretation

bagels and cream cheese ftw

Maybe we should close this one and try again.

FWIW, I interpreted the poll as:

Do you use a tab character (\t or 0x09) or space character(s) (0x20) for indenting (not lining up) your code?
If you use space characters, how many do you use for an indent?
If you use the tab character, what width (in number of space characters) do you prefer your editor to *display* the tab character as?
(This is NOT asking what key you press to do the indenting. It's asking what character(s) you use for indenting.)
 
tabs, well, soft tabs

but i hardly indent myself, i program in netbeans, and a single ctrl+shift+f propperly indents the source im working with
 
Back
Top