Page 1 of 2
Tabs or Spaces?
Posted: Sun Oct 26, 2014 3:58 am
by Kingdaro
I'm curious, and maybe we can get sort of a discussion going here. Which is your preference, and why? If you use tabs, what is your tab width? If you use spaces, how many? If you use a mix of the two, how so?
Re: Tabs or Spaces?
Posted: Sun Oct 26, 2014 4:24 am
by Zilarrezko
I tab with a 2 wide space.
I use tabs because If I mixed them, It would look wonky if someone else had a different tab width. Like on my laptop when I code at school, where my tab width is 3 oddly enough. (It's that compressed 1080p screen I'm sure.)
Re: Tabs or Spaces?
Posted: Sun Oct 26, 2014 7:32 am
by Davidobot
I use Sublime with just tabs, which will equal to 4 spaces. (I have a big monitor)
Re: Tabs or Spaces?
Posted: Sun Oct 26, 2014 8:58 am
by kikito
Spaces only. Two per level. My tab key produces spaces, and I have a editor command which replaces tabs with spaces.
Re: Tabs or Spaces?
Posted: Sun Oct 26, 2014 10:01 am
by zorg
Until my code is ready to be released, tabs, since i use the same editor always, so it will always look the same, and before releasing, i convert them to 4 spaces.
Re: Tabs or Spaces?
Posted: Sun Oct 26, 2014 12:28 pm
by kikito
Here's what some "big guys" are doing regarding spacing:
Spaces:
- The Lua-users page recommends 2 spaces, no tabs
- The OlivineLabs guys use 2 spaces, no tabs
- In Programming in Lua, all the examples use 2 spaces, no tabs (example).
- The examples in the Lua Reference Manual also use 2 spaces, no tabs (example).
- The examples in Beginning Lua Programming all use 2 spaces, no tabs. I could not find an online abstract to link examples.
Tabs:
Re: Tabs or Spaces?
Posted: Sun Oct 26, 2014 1:14 pm
by bartbes
kikito wrote:
Spaces:
- The Lua-users page recommends 2 spaces, no tabs
- The OlivineLabs guys use 2 spaces, no tabs
- In Programming in Lua, all the examples use 2 spaces, no tabs (example).
- The examples in the Lua Reference Manual also use 2 spaces, no tabs (example).
- The examples in Beginning Lua Programming all use 2 spaces, no tabs. I could not find an online abstract to link examples.
I'm a tab guy myself, but don't take this as me claiming my superior choice. These are all examples (except the OlivineLabs one, maybe) of displaying code in (virtual) print. In my mind is only obvious that spaces are used in print, because often you care about how the website looks. Also note that html, for instance, is more suited to printing spaces than tabs.
That said, this discussion is completely pointless, there are no benefits either way. Use what you like best, or what the project you're working on uses (so start projects, you get to decide!). I think the worst outcome of discussions like these is programming languages forcing the usage of one over the other.
As an extra illustration, the LÖVE codebase uses tabs for indentation and spaces for alignment, and if it were any other way, it would still be LÖVE.
Re: Tabs or Spaces?
Posted: Sun Oct 26, 2014 4:57 pm
by Jasoco
Tabs. Tabs tabs tabs.
Re: Tabs or Spaces?
Posted: Mon Nov 03, 2014 5:20 am
by Positive07
I use tabs and let github resolve the width by himself (it lets you chose between 2, 4, 6... spaces)
If I download a library/code/snippet or something I just use Notepad++, take a copy of the number of spaces used to indent, and replace it with a tab... it's really easy so I have no problem
I use tab because:
- Its just one keypress
- I can delete it with a single keypress
- Allows me to select lots of text and press tab once to indent it all (or shift tab to un-indent it)
Again, this is what I like and what I'm used to, not the final answer
Re: Tabs or Spaces?
Posted: Mon Nov 03, 2014 5:41 am
by ivan
It's 2 spaces for me. Notepad++ has a setting that overwrites tabs with spaces automatically.
Another reason to use spaces is that tabs may be displayed differently by different editors.