Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Tabs vs Spaces

Tabs vs Spaces

Scheduled Pinned Locked Moved The Lounge
visual-studiohelpquestion
63 Posts 43 Posters 23 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K k5054

    FreedMalloc wrote:

    I generally set up the IDE to sub 4 spaces for a tab.

    Infidel! All right-minded people know that a tab stop is every 8 spaces! Anything else is heresy! Your immortal soul will be condemned to an eternity in an infinite loop unless you repent!

    Keep Calm and Carry On

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #20

    I never understood that, 8 spaces per tab, on a teletype of all things - sheer lunacy.

    O 1 Reply Last reply
    0
    • K Kevin Marois

      Quick survey... How many of you uses tabs vs spaces to indent your code?

      If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

      D Offline
      D Offline
      den2k88
      wrote on last edited by
      #21

      I prefer tabs because when I have to move code from an indentation level to another it requires less deletes. Also allows for fancy editing like a different character width for indentation than for code (it helps for people who have to set the font to 12pt with 125% or 150% magnification active, like yours truly). Also I have worked on a codebase modified by several people in several years with different tools and different indentations. Code was something like

      if (condition){
      code;
      if (cnd2)
      {
      code;
      }
      code;
      while(something)
      {
      code;
      }
      }

      Tabs would have fixed the lunacy.

      GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

      1 Reply Last reply
      0
      • W Wizard of Sleeves

        2½ spaces per tab

        Nothing succeeds like a budgie without teeth. To err is human, to arr is pirate.

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #22

        :sigh: There's always someone who just wants to watch the world burn, isn't there? OK. You can have your half-a-space provided it's the top half.

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • K Kevin Marois

          Quick survey... How many of you uses tabs vs spaces to indent your code?

          If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

          A Offline
          A Offline
          acego
          wrote on last edited by
          #23

          I normally use Tab key (4 spaces) but it also depends on the IDE

          1 Reply Last reply
          0
          • K Kevin Marois

            Quick survey... How many of you uses tabs vs spaces to indent your code?

            If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

            C Offline
            C Offline
            Cpichols
            wrote on last edited by
            #24

            I use a 2-space tab.

            1 Reply Last reply
            0
            • Greg UtasG Greg Utas

              I would've never thought there could be a good argument for tabs, but this sounds like a good way to satisfy everyone. My only question would be what the code looks like outside the IDE, in GitHub or even Notepad, for example.

              Robust Services Core | Software Techniques for Lemmings | Articles
              The fox knows many things, but the hedgehog knows one big thing.

              C Offline
              C Offline
              Cpichols
              wrote on last edited by
              #25

              I only care about what it looks like to the one working on the code. When dealing with changes to legacy code, I follow the patter established, which usually means copy/paste of the disparate numbers of spaces depending on the mood of the coder when it was created in notepad :wtf: I really hate the ripple effect that gives - I mean choose an indentation style and stick with it. I'm happiest when working on fresh apps where I can use auto indenting on vscode. So much pleasanter and I can properly collapse the bits I don't need to see right now. Why would I screw that up with using spaces? Just no.

              Greg UtasG 1 Reply Last reply
              0
              • C Cpichols

                I only care about what it looks like to the one working on the code. When dealing with changes to legacy code, I follow the patter established, which usually means copy/paste of the disparate numbers of spaces depending on the mood of the coder when it was created in notepad :wtf: I really hate the ripple effect that gives - I mean choose an indentation style and stick with it. I'm happiest when working on fresh apps where I can use auto indenting on vscode. So much pleasanter and I can properly collapse the bits I don't need to see right now. Why would I screw that up with using spaces? Just no.

                Greg UtasG Offline
                Greg UtasG Offline
                Greg Utas
                wrote on last edited by
                #26

                What does using spaces have to do with collapsing code that you don't need to see right now?

                Robust Services Core | Software Techniques for Lemmings | Articles
                The fox knows many things, but the hedgehog knows one big thing.

                <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
                <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

                C 2 Replies Last reply
                0
                • K Kevin Marois

                  Quick survey... How many of you uses tabs vs spaces to indent your code?

                  If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

                  J Offline
                  J Offline
                  JohnDG52
                  wrote on last edited by
                  #27

                  I prefer tabs - but the VS editor seems to have it's own idea about how they should be rendered, so I often end up using a mixture.

                  1 Reply Last reply
                  0
                  • Greg UtasG Greg Utas

                    What does using spaces have to do with collapsing code that you don't need to see right now?

                    Robust Services Core | Software Techniques for Lemmings | Articles
                    The fox knows many things, but the hedgehog knows one big thing.

                    C Offline
                    C Offline
                    Cpichols
                    wrote on last edited by
                    #28

                    You should see this crazy code. It was like they decided arbitrarily each day where to start their nested content.

                    code
                    

                    condition
                    {
                    code
                    condition
                    {
                    super long lines of code that go all the way off a standard screen with references to deeply nested arrays
                    }
                    other code
                    }

                    C Greg UtasG S 3 Replies Last reply
                    0
                    • C Cpichols

                      You should see this crazy code. It was like they decided arbitrarily each day where to start their nested content.

                      code
                      

                      condition
                      {
                      code
                      condition
                      {
                      super long lines of code that go all the way off a standard screen with references to deeply nested arrays
                      }
                      other code
                      }

                      C Offline
                      C Offline
                      Cpichols
                      wrote on last edited by
                      #29

                      Yeah that didn't translate right; guess I should have used " "

                      1 Reply Last reply
                      0
                      • Greg UtasG Greg Utas

                        What does using spaces have to do with collapsing code that you don't need to see right now?

                        Robust Services Core | Software Techniques for Lemmings | Articles
                        The fox knows many things, but the hedgehog knows one big thing.

                        C Offline
                        C Offline
                        Cpichols
                        wrote on last edited by
                        #30

                        Plus it's way easier to screw up the number of spaces needed. I guess that IDEs can be set to auto indent with spaces, but if someone else goes in there with notepad, it'll be a mess in a hurry. Using tabs discourages the use of notepad. Is that controlling? Maybe. I am a megalomaniac only in the coding, otherwise I'm very accommodating, so I'm comfortable with that.

                        1 Reply Last reply
                        0
                        • C Cpichols

                          You should see this crazy code. It was like they decided arbitrarily each day where to start their nested content.

                          code
                          

                          condition
                          {
                          code
                          condition
                          {
                          super long lines of code that go all the way off a standard screen with references to deeply nested arrays
                          }
                          other code
                          }

                          Greg UtasG Offline
                          Greg UtasG Offline
                          Greg Utas
                          wrote on last edited by
                          #31

                          That's beyond sloppy. I would reformat it, and anyone who complained would be auditioning for a boys' choir.

                          Robust Services Core | Software Techniques for Lemmings | Articles
                          The fox knows many things, but the hedgehog knows one big thing.

                          <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
                          <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

                          C 1 Reply Last reply
                          0
                          • C Cpichols

                            You should see this crazy code. It was like they decided arbitrarily each day where to start their nested content.

                            code
                            

                            condition
                            {
                            code
                            condition
                            {
                            super long lines of code that go all the way off a standard screen with references to deeply nested arrays
                            }
                            other code
                            }

                            S Offline
                            S Offline
                            steve tabler
                            wrote on last edited by
                            #32

                            I'm regularly asked by other coders to fix code or tweak code that is formattwed like this, or worse. U like my indents to be a consistant 1/4 inch so the long lines of code don't wrap because they have several levels of indent in them. Just give me Allsup (ANSI) format.

                            1 Reply Last reply
                            0
                            • P PIEBALDconsult

                              No, TAB stops are by distance, not character count. A half inch is sufficient.

                              T Offline
                              T Offline
                              Techsys Admin
                              wrote on last edited by
                              #33

                              You've got a point there. Word and WordPad (and many others, I'm sure) default to a proportional font so the default tab is 1/2 inch. Oddly, with a monospace fonts, I don't even consider the distance, per se, but instead a sufficient number of characters to make it read comfortably. Perhaps others do this? In any case, I normally choose 4 characters for the tab length in those files but I may have been influenced by so many editors choosing that same number.

                              1 Reply Last reply
                              0
                              • K Kevin Marois

                                Quick survey... How many of you uses tabs vs spaces to indent your code?

                                If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

                                M Offline
                                M Offline
                                Mark Starr
                                wrote on last edited by
                                #34

                                Indent? That’s really a thing? I just left-align everything. Tried right-align, but that was messy. :)

                                Time is the differentiation of eternity devised by man to measure the passage of human events. - Manly P. Hall Mark Just another cog in the wheel

                                G 1 Reply Last reply
                                0
                                • K Kevin Marois

                                  Quick survey... How many of you uses tabs vs spaces to indent your code?

                                  If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

                                  U Offline
                                  U Offline
                                  User 11566074
                                  wrote on last edited by
                                  #35

                                  I use spaces (inserted using the Tab key) according to the language: Python - 4 as is the usual setting, HTML/JavaScript: 2 because otherwise indenting of HTML tends to become too high to be comfortable.

                                  1 Reply Last reply
                                  0
                                  • Greg UtasG Greg Utas

                                    That's beyond sloppy. I would reformat it, and anyone who complained would be auditioning for a boys' choir.

                                    Robust Services Core | Software Techniques for Lemmings | Articles
                                    The fox knows many things, but the hedgehog knows one big thing.

                                    C Offline
                                    C Offline
                                    Cpichols
                                    wrote on last edited by
                                    #36

                                    Yes, I tried that in the first few weeks of my job and got in major trouble because git was a Christmas tree. And they just ignored my branches because of it. Low man on totem pole.

                                    1 Reply Last reply
                                    0
                                    • L Lost User

                                      I never understood that, 8 spaces per tab, on a teletype of all things - sheer lunacy.

                                      O Offline
                                      O Offline
                                      obermd
                                      wrote on last edited by
                                      #37

                                      I think it had to do with what a mechanical typewriter was able to reliably insert. Remember, the tab key didn't shift x spaces, it shifted to the next tab stop, and yes, these were physical stops in a mechanical typewriter. Since these old machines worked on a fixed width font of 8 characters per inch and the physical tab stops were one inch apart, a tab became associated with 8 characters.

                                      S 1 Reply Last reply
                                      0
                                      • M Mike Hankey

                                        Beer cans used to have tabs...so I prefer tabs. :)

                                        PartsBin an Electronics Part Organizer - A updated version available! JaxCoder.com

                                        M Offline
                                        M Offline
                                        megaadam
                                        wrote on last edited by
                                        #38

                                        I fine with that as long as you pick up the tab!

                                        "If we don't change direction, we'll end up where we're going"

                                        M 1 Reply Last reply
                                        0
                                        • M megaadam

                                          I fine with that as long as you pick up the tab!

                                          "If we don't change direction, we'll end up where we're going"

                                          M Offline
                                          M Offline
                                          Mike Hankey
                                          wrote on last edited by
                                          #39

                                          Not any more Tab Soda 12 Pack Soft Drinks Tab Soda Discontinued 🥤02/2021 | eBay[^]

                                          PartsBin an Electronics Part Organizer - A updated version available! JaxCoder.com

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups