What type of indents in java do you prefer, tabs or spaces?

Discussion in 'Programming' started by bottomdumber, Jun 24, 2019.

?

What type of indents in java do you prefer, tabs or spaces?

  1. I use tabs

    21 vote(s)
    55.3%
  2. I use spaces

    14 vote(s)
    36.8%
  3. I am in a fog

    3 vote(s)
    7.9%
  1. Hello
    I am interesting what type of indents in java do you prefer, tabs or spaces?
    And what tab length do you use, 4 or 8 spaces?
     
  2. Tab and 4, who the heck uses 8?
     
    • Like Like x 2
  3. Google Code Style and an IDE that converts tabs to spaces.
     
    • Like Like x 1
  4. Strahan

    Benefactor

    Spaces, and I like a tab length of 2. I hate excessive indentation.
     
    • Like Like x 1
    • Agree Agree x 1
  5. I prefer 2 spaces, given how indented Java code tends to become (in comparison to e.g. Rust which usually is at 4 spaces/a single indent most of the time).
     
    • Like Like x 1
  6. I use 4 for java, and 2 for web dev. Spaces are a necessity, so indentation renders properly on github.
     
    • Like Like x 1
  7. Alright, people are gonna hate me for this. Mixed. Yes, I said it, I use both spaces and tabs and it honestly doesn't bother me.

    A .editorconfig file ensures that GitHub, as well as my IDE, renders tabs as four spaces and when I use spaces, I use four. Code is still indented properly everywhere and I don't have to force myself to use either one or the other. I think my IDE is set at using spaces for indentation though, so that's probably what most of my project uses, but there may be tabs in there as well.

    I usually follow the if-not-return principle to keep indents minimal whenever possible, so four spaces for tabs doesn't really bother me either.
     
    • Like Like x 1
  8. 2 everywhere and always spaces. Tabs are evil
     
    • Like Like x 1
  9. 4 spaces. No tabs.
     
    • Like Like x 1
  10. clip

    Benefactor

    Google code style here
     
    • Like Like x 1
  11. Single line code for the win!
    Just kidding... Tabs please
     
    • Like Like x 1
  12. MiniDigger

    Supporter

    4 spaces + a proper ide that handles indentation properly.
     
    • Agree Agree x 2
    • Like Like x 1
  13. At work we use 4 but for personal I try to use 2 spaces. It’s always trippy going back and forth but I prefer 2 personally
     
    • Like Like x 1
    • Agree Agree x 1
  14. 4 spaces per indentation, and always tab's.

    The reason why i prefer to use 4 instead of 2 is because it's easily visible, and if there are too much tabs to keep a good overview there's most likely something too complicated or non-optimized in your code anyway ;)
     
  15. how can you use spaces and tabs at the same time...?
     
  16. 2 spaces.

    4 spaces be like:
    Code (Text):
    four-spaces:
                                                       suck: "!"
     
  17. What i meant was that when i tab, the size of the indentation is equal to 4 spaces ;)
     
    • Like Like x 1
  18. Actually, now that I look into my IntelliJ IDEA editor i actually use 2 space indentations, and once again use the tab key to indent code.
     
  19. Just because you use the tab key doesn’t mean you’re using tabs. Often text editors/ides automatically convert your tabs to spaces, unless specifically configured not to.
     
  20. Oh yeah okay. You can configure that in pretty much every IDE, but I indeed have the same where it's configured to 4 spaces.