

Ask HN: Code etiquette - tabs or spaces? - PStamatiou

I like putting coding with tabs only but I've been told that using spaces is more uniform across various IDEs/what have you.<p>what do you use?
======
cperciva
To quote BSD style(9): _Indentation is an 8 character tab. If you have to wrap
a long statement [because it would go past the 78th column], put the operator
at the end of the line. Second level indents are four spaces. Do not add
whitespace at the end of a line, and only use tabs followed by spaces to form
the indentation. Do not use more spaces than a tab will produce and do not use
spaces in front of tabs._

If you find that your code doesn't fit into 78 columns using 8-character
tabs... you need to refactor your code.

If your editor mangles whitespace... get a better editor.

~~~
ScottWhigham
Why would someone downvote this? It's the guy/girl's opinion, it's about the
topic, and I don't see any reason to downvote other than someone is just
having a bad day or being pissy.

------
simianstyle
My theory is that your IDE should be able to adjust the amount of spaces that
1 tab is equal to, and therefore the whitespace is adjustable across editors
that way - so I always use tabs.

But if you're so anal about whitespace, there's always regex...

------
wallflower
All the companies I have worked at have enforced spaces by setting up the
editor to translate tabs to 4 spaces. I never asked why. Some battles aren't
worth fighting.

'Spaces instead of tabs' wasn't the near the near-religious fervour of which
editor to use though (VSlick won at my 1st company - e.g. company bought group
license - though you could buy your own fave). I guess if you spend all day
working with a hammer, you want the best hammer for you. I've spent hundreds
of my own to buy my own editor to use at work.

------
brianr
If you're writing Python, the convention is spaces. From PEP 8:

    
    
      Indentation
    
        Use 4 spaces per indentation level.
    

(see <http://www.python.org/dev/peps/pep-0008/>)

I'm partial to spaces in general. Most (all?) IDEs can insert spaces when you
press the tab key, and doing so will prevent the nastiness that can happen
when you mix spaces with tabs.

------
ScottWhigham
Personally I use whatever the editor that the team uses uses as the default (
_that's right "uses uses", baby! Don't get many opportunities for that!_ ).
I'm a big fan of using the defaults when it comes to development. I want to be
able to step over to a co-worker's or temporary machine, do my work, check it
in and not have to worry whether we used spaces or tabs.

------
newt0311
whitespace. Tabs are non-standard across systems and of a non-unit length and
so when custom continuation lines are indented, they have to use a mix which
wreaks havoc when the tab length goes from 4 to say 8 or vice versa. If you
are interested in re-indenting code, then use a program/command that is
actually designed for code re-indentation, not some inaccurate stupid shortcut
like tab length manipulation. Pretty much any modern IDE would have a code re-
indentation infrastructure.

~~~
baha_man
Tabs _are_ whitespace.

~~~
newt0311
My apologies. Spaces.

