Search Unity

Question Vote: Tabs or Spaces

Discussion in 'Open Projects' started by Kamyker, Oct 1, 2020.

?

Pick one forever

  1. Tabs

    101 vote(s)
    77.7%
  2. Spaces

    29 vote(s)
    22.3%
Thread Status:
Not open for further replies.
  1. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
  2. DaSerialGenius

    DaSerialGenius

    Joined:
    Jun 27, 2017
    Posts:
    17
    Mind you there is a correct answer
     
  3. MileyUnity

    MileyUnity

    Joined:
    Jan 3, 2020
    Posts:
    92
    The correct answer in this is what we can align on as a community, it's purely a preference and has no real impact on the final product :)
     
  4. Skjalg

    Skjalg

    Joined:
    May 25, 2009
    Posts:
    211
  5. KingAustin

    KingAustin

    Joined:
    Jan 12, 2016
    Posts:
    20
    i dont understand the question
     
  6. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    I'm fine with whatever people prefer, I don't use Notepad so I should be able to just setup my IDE to match the community's preference.
     
  7. ouraf

    ouraf

    Joined:
    Sep 4, 2019
    Posts:
    18
    IDEs normally have tabs as the default option, I think.
     
  8. hrkrx

    hrkrx

    Joined:
    Feb 9, 2019
    Posts:
    6
    I do prefer spaces, but aside from the visually impaired, are there other benefits to tabs that outweigh the negatives?

    I'd really like to get some answers here as so many people seem to prefer tabs (honestly I thought everyone would prefer spaces)
     
    GregoryFenn likes this.
  9. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
    Adding or removing one tab is quicker than 2+ spaces.
     
    MileyUnity and Proryanator like this.
  10. hrkrx

    hrkrx

    Joined:
    Feb 9, 2019
    Posts:
    6
    isn't any decent IDE (even vim) catching the TAB and inserting a predefined number of spaces? so speed is not an Issue
     
    RodrigoAbreu and Proryanator like this.
  11. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
    Inserting yes but not removing.
     
    MileyUnity, Neto_Kokku and ouraf like this.
  12. tacman1123

    tacman1123

    Joined:
    Sep 14, 2020
    Posts:
    77
    The problem with tabs, and it's a HUGE problem, is that many IDE's are set up to automatically expand tabs, so every commit (in github, at least) is going to create a largely irrelevant changelist.
    ,
    YAML, which is the format of the .asset files, does not allow tabs. Even if the Unity parser does (not sure if that's the case).

    Absolutely we should be using spaces for any .asset and .cs file, and we should agree on some style guide as to 2 or 4 or whatever number of spaces. But tabs are terribly problematic for a team effort, and shouldn't be allowed.
     
    RodrigoAbreu likes this.
  13. MileyUnity

    MileyUnity

    Joined:
    Jan 3, 2020
    Posts:
    92
    Why would every commit create a largely irrelevant change-list if the entire project is already setup to use tabs over spaces if we make that decision? At best there would be a set of commits at first that would do this in order to align the entire project to tabs over spaces but once that’s done there’s no more extra empty lines to be committed.

    Tabs can also be changed to whatever size you want them in most IDEs so you yourself can decide whether you want a tab character to be 2 or 4 spaces in size without it impacting anyone else meaning that we don’t even have to align on how big the indentations should be.

    I see more upsides than downsides to using tabs over spaces and the Reddit post that @Skjalg posted provided a very good argument to why we should use tabs over spaces.
     
    Skjalg likes this.
  14. hrkrx

    hrkrx

    Joined:
    Feb 9, 2019
    Posts:
    6
    CTRL + Backspace is the shortcut that solves even this problem, so speed really shouldn't be the deciding factor if we use tabs or spaces.
     
  15. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
    .editorconfig file overrides IDEs settings.
    speed of clicking 1 button > speed of clicking 2 buttons
     
  16. RodrigoAbreu

    RodrigoAbreu

    Joined:
    Jan 29, 2013
    Posts:
    12
    Yeah, it's the case for almost all code review tools.
     
  17. Harsh-NJ

    Harsh-NJ

    Joined:
    May 1, 2020
    Posts:
    315
    Yes, tabs are normally used and they should be. It is easier to use tab once than using spaces four times.
     
  18. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    Most IDEs support tabs inserting a configurable number of spaces.
     
    Harsh-NJ likes this.
  19. MileyUnity

    MileyUnity

    Joined:
    Jan 3, 2020
    Posts:
    92
    Closing this thread as the decision has been made to go with Tabs instead of Spaces :)
     
    alexchesser likes this.
Thread Status:
Not open for further replies.