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 27 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.
  • 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
                  • 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.

                    T Offline
                    T Offline
                    TNCaver
                    wrote on last edited by
                    #40

                    Tabs. Converting the tabs to spaces in my code is a capital offense with immediate execution of the sentence.

                    If you think 'goto' is evil, try writing an Assembly program without JMP.

                    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

                      C Offline
                      C Offline
                      Choroid
                      wrote on last edited by
                      #41

                      Competition for your "PartsBin" Wait... What? I Made a Small Parts Organizer with Drawers from Cardboard! - YouTube[^] Perhaps include this as an add on

                      M 1 Reply Last reply
                      0
                      • C Choroid

                        Competition for your "PartsBin" Wait... What? I Made a Small Parts Organizer with Drawers from Cardboard! - YouTube[^] Perhaps include this as an add on

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

                        Awesome thanks for the link. Good storage alternative, especially since the organizers are so dang expensive.

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

                        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
                          Member_15777962
                          wrote on last edited by
                          #43

                          I use Tabs for Columns, and spaces for strings, Carriage Return/Line Feed for new Row. Makes sense when Using Excel. For notepad it doesn't matter :-)

                          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.

                            J Offline
                            J Offline
                            Jim Spencer100
                            wrote on last edited by
                            #44

                            If(spaceToAdd > 1) { Tab(); } else { Space(); } // This is how my brain does it :P

                            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.

                              E Offline
                              E Offline
                              englebart
                              wrote on last edited by
                              #45

                              I prefer tabs. Our code size in bytes could double or quadruple or ? based on how many spaces were substituted. A lot of lines in brace delimited languages are 8 tabs, open or close brace. Python, stick to spaces!

                              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.

                                S Offline
                                S Offline
                                StatementTerminator
                                wrote on last edited by
                                #46

                                I use tab and shift+tab in VS to keep things in neat code blocks. I don't really care how many spaces a tab is as long as it's consistent (I use the default). I've never seen a good reason to use spaces, whenever I see code like that it's usually a mess. It's possible to format code well using spaces, but that's not what I usually see in the wild.

                                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.

                                  J Offline
                                  J Offline
                                  Juan Pablo Reyes Altamirano
                                  wrote on last edited by
                                  #47

                                  If it doesn't auto-indent, I will tab. But now I wonder if K&R C had anything to say about that :~

                                  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.

                                    J Offline
                                    J Offline
                                    James Curran
                                    wrote on last edited by
                                    #48

                                    I use Tabs (as the Good Lord Intended)

                                    Truth, James

                                    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.

                                      G Offline
                                      G Offline
                                      Gary R Wheeler
                                      wrote on last edited by
                                      #49

                                      I used tabs until Visual Studio .NET 2003 unrecoverably broke the block indent/undent operation when you mixed tabs and spaces. After that I switched to spaces. And yes, this same operation has been broken ever since. VC6 would let you have {tab}{tab}{sp}{sp}stuff, and when you indented, that became {tab}{tab}{tab}{sp}{sp}stuff. All versions since then have stripped the leading tabs and/or spaces and inserted N tabs or N*s spaces. Studio has been through more than one editor rewrite since then, and it still doesn't work right. I'm using VS2019 now, and it occasionally decides to treat indents as blocks. It's not predictable though.

                                      Software Zen: delete this;

                                      1 Reply Last reply
                                      0
                                      • M Mark Starr

                                        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 Offline
                                        G Offline
                                        Gary R Wheeler
                                        wrote on last edited by
                                        #50

                                        Use RTL text (or even better bidi), I dare you.

                                        Software Zen: delete this;

                                        1 Reply Last reply
                                        0
                                        • P PIEBALDconsult

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

                                          O Offline
                                          O Offline
                                          ormonds
                                          wrote on last edited by
                                          #51

                                          Inches? I still use cubits.

                                          P 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