Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A tab does not mean 8 spaces. That's the whole problem, people keep thinking tabs and spaces have an exchange rate.

If you have a source file with only tabs (and you should, then nobody has to run an re-indent script because they can't read it), you should be inserting tabs. If you have a source file with only spaces, you should map the tab key to insert the correct amount of spaces before editing. If you have a source file with both tabs and spaces for indentation, you should re-indent.



For all purposes, yes it means 8 spaces.

Type this in a bash terminal: $ printf '1234567890\n\tx\n'

For the second paragraph: I couldn't agree more. There's even some "geniuses" that indent python with the 1st level being 4 spaces and the second level as a tab. * sigh *. Really.


What about this?

  printf '1234567890\n1\tx\n12\tx\n123\tx\n1234\tx'
  1234567890
  1	x
  12	x
  123	x
  1234	x
Tabs are not fixed width, that's the whole point of their existence.


Yes, this is how it works for alignment, so you don't need spaces to align the x there

This is a non issue when you have nothing to the left of the code (that is, when indenting)

(and the x should be under the 9 btw)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: