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. Spaces vs. Tabs

Spaces vs. Tabs

Scheduled Pinned Locked Moved The Lounge
visual-studioarchitecturequestion
25 Posts 18 Posters 26 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.
  • R realJSOP

    The problem is when you convert your tabs to spaces, and someone else uses a different tab setting (more or fewer spaces). Alignment problems about. Tabs are better. To hell with those thin-skinned pillow-biters. - Me, 10/03/2001

    T Offline
    T Offline
    Tim Smith
    wrote on last edited by
    #6

    Not true at all. Try a tab setting of 8 and an indent of 4. Tim Smith Descartes Systems Sciences, Inc.

    L 1 Reply Last reply
    0
    • T Tim Smith

      Not true at all. Try a tab setting of 8 and an indent of 4. Tim Smith Descartes Systems Sciences, Inc.

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

      Doesn't VC++ auto-format use tabs? In the space/tab issue, I prefer to be a bozo. Thomas

      T 1 Reply Last reply
      0
      • R realJSOP

        The problem is when you convert your tabs to spaces, and someone else uses a different tab setting (more or fewer spaces). Alignment problems about. Tabs are better. To hell with those thin-skinned pillow-biters. - Me, 10/03/2001

        C Offline
        C Offline
        Chris Losinger
        wrote on last edited by
        #8

        our coding standard says, in effect "tabs as spaces. 3 spaces". if everyone has the same setting, there is no issue. -c


        Smaller Animals Software, Inc. http://www.smalleranimals.com

        R A 2 Replies Last reply
        0
        • P Paul Lyons

          Color me ignorant :confused:! Why are some people so vigorously opposed to tabs in source code? I came accross this statement at someones "MVP" website... "people who insist on using tabs to layout their code (i.e. bozos)".:mad: <-ouch that's harsh!-> What are the advantages of spaces versus the disadvantages of tabs? "Do not go where the path may lead, go instead where there is no path and leave a trail." - Ralph Waldo Emerson

          A Offline
          A Offline
          Alvaro Mendez
          wrote on last edited by
          #9

          OK, let's see if I can do an accurate analysis: Spaces Pros - The code looks the same in any editor. - When you move the cursor up and down the file, it stays in the same column (unless the line is too short). Cons - The code is forced to be indented the exact number of spaces desired by its writer. If someone wants to see more or less indented spaces, they can't. - Say you set your editor to insert 4 spaces for every tab. The problem is that if you press Tab and then change your mind, you'll need to press Backspace 4 times to delete it. Tabs Pros - Allows different programmers to view the same code differently, by assigning their own number of spaces for each tab. - Tabs are treated as one character so when you press Backspace, you appear to be deleting several spaces at once. This makes some people (like me) more productive. Cons - They can cause block comments on the right side of the code to not line up properly between different tab settings. This is obvious when you develop a CPP file in DevStudio and then later open it in Notepad. - They look just like spaces so it's hard know that they're there (which I don't care much about). Tabs Rule! Regards, Alvaro

          B 1 Reply Last reply
          0
          • A Alvaro Mendez

            OK, let's see if I can do an accurate analysis: Spaces Pros - The code looks the same in any editor. - When you move the cursor up and down the file, it stays in the same column (unless the line is too short). Cons - The code is forced to be indented the exact number of spaces desired by its writer. If someone wants to see more or less indented spaces, they can't. - Say you set your editor to insert 4 spaces for every tab. The problem is that if you press Tab and then change your mind, you'll need to press Backspace 4 times to delete it. Tabs Pros - Allows different programmers to view the same code differently, by assigning their own number of spaces for each tab. - Tabs are treated as one character so when you press Backspace, you appear to be deleting several spaces at once. This makes some people (like me) more productive. Cons - They can cause block comments on the right side of the code to not line up properly between different tab settings. This is obvious when you develop a CPP file in DevStudio and then later open it in Notepad. - They look just like spaces so it's hard know that they're there (which I don't care much about). Tabs Rule! Regards, Alvaro

            B Offline
            B Offline
            Brad Bruce
            wrote on last edited by
            #10

            Click the toolbar button with the little ab with a dot in the middle. That will show you your tabs.

            1 Reply Last reply
            0
            • L Lost User

              Doesn't VC++ auto-format use tabs? In the space/tab issue, I prefer to be a bozo. Thomas

              T Offline
              T Offline
              Tim Smith
              wrote on last edited by
              #11

              In VC there are 3 tab options, "Keep tabs", "Tab size", and "Indent size". When the indent size isn't the same as the tab size, you get a nasty mixture of the two. Personally, I use tab/indent setting of 4. Most all of my code is in house so I don't care about the rest of the world. Tim Smith Descartes Systems Sciences, Inc.

              R 1 Reply Last reply
              0
              • T Tim Smith

                In VC there are 3 tab options, "Keep tabs", "Tab size", and "Indent size". When the indent size isn't the same as the tab size, you get a nasty mixture of the two. Personally, I use tab/indent setting of 4. Most all of my code is in house so I don't care about the rest of the world. Tim Smith Descartes Systems Sciences, Inc.

                R Offline
                R Offline
                realJSOP
                wrote on last edited by
                #12

                You're right. And Ditto. I wish all programmers had gotten used to this way of thinking. To hell with those thin-skinned pillow-biters. - Me, 10/03/2001

                1 Reply Last reply
                0
                • C Chris Losinger

                  our coding standard says, in effect "tabs as spaces. 3 spaces". if everyone has the same setting, there is no issue. -c


                  Smaller Animals Software, Inc. http://www.smalleranimals.com

                  R Offline
                  R Offline
                  realJSOP
                  wrote on last edited by
                  #13

                  At work, we have the same rule and it SUCKS. :) At home, I use indent/tab set at 4 spaces (keep tabs). To hell with those thin-skinned pillow-biters. - Me, 10/03/2001

                  1 Reply Last reply
                  0
                  • P Paul Lyons

                    Color me ignorant :confused:! Why are some people so vigorously opposed to tabs in source code? I came accross this statement at someones "MVP" website... "people who insist on using tabs to layout their code (i.e. bozos)".:mad: <-ouch that's harsh!-> What are the advantages of spaces versus the disadvantages of tabs? "Do not go where the path may lead, go instead where there is no path and leave a trail." - Ralph Waldo Emerson

                    R Offline
                    R Offline
                    Ravi Bhavnani
                    wrote on last edited by
                    #14

                    The simple answer is that it costs approximately 4 times as much to maintain code than to produce it. I can't remember where I read this, but I'll try and dig up the source. Therefore it makes sense to code in a uniform, developer agnostic manner. That's one reason why programming shops use coding guidelines. Spaces are by definition independent of tab sizes, and are hence independent of the developer's preferences. Similar arguments may be made for using Hungarian notation, JavaDoc style comment headers, etc. If you're the only person who will create/modify a code base, you should feel free to use tabs (or spaces). Further reading

                    • SEI
                    • Xtreme Programming

                    /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

                    1 Reply Last reply
                    0
                    • C Chris Losinger

                      our coding standard says, in effect "tabs as spaces. 3 spaces". if everyone has the same setting, there is no issue. -c


                      Smaller Animals Software, Inc. http://www.smalleranimals.com

                      A Offline
                      A Offline
                      Anders Molin
                      wrote on last edited by
                      #15

                      if everyone has the same setting, there is no issue. That's right, but... Lot's of people use a tab-setting of 4, and I only use 2. When we all use tabs, they see my code like they want, and I can look at their code the way I like it. :) I would really hate to be forced to use 4 spaces... X| - Anders Money talks, but all mine ever says is "Goodbye!"

                      A 1 Reply Last reply
                      0
                      • A Anders Molin

                        if everyone has the same setting, there is no issue. That's right, but... Lot's of people use a tab-setting of 4, and I only use 2. When we all use tabs, they see my code like they want, and I can look at their code the way I like it. :) I would really hate to be forced to use 4 spaces... X| - Anders Money talks, but all mine ever says is "Goodbye!"

                        A Offline
                        A Offline
                        A A 0
                        wrote on last edited by
                        #16

                        Same here, two is the prefered. Though does anyone know whether some code editors embed a tab with a special marker? I heard this long ago, as to why not to use tabs. Though it could be back in the days when memory was scarce:)

                        1 Reply Last reply
                        0
                        • P Paul Lyons

                          Color me ignorant :confused:! Why are some people so vigorously opposed to tabs in source code? I came accross this statement at someones "MVP" website... "people who insist on using tabs to layout their code (i.e. bozos)".:mad: <-ouch that's harsh!-> What are the advantages of spaces versus the disadvantages of tabs? "Do not go where the path may lead, go instead where there is no path and leave a trail." - Ralph Waldo Emerson

                          P Offline
                          P Offline
                          peterchen
                          wrote on last edited by
                          #17

                          The absolute proof for Paul Watson's statement....

                          P 1 Reply Last reply
                          0
                          • P Paul Lyons

                            Color me ignorant :confused:! Why are some people so vigorously opposed to tabs in source code? I came accross this statement at someones "MVP" website... "people who insist on using tabs to layout their code (i.e. bozos)".:mad: <-ouch that's harsh!-> What are the advantages of spaces versus the disadvantages of tabs? "Do not go where the path may lead, go instead where there is no path and leave a trail." - Ralph Waldo Emerson

                            A Offline
                            A Offline
                            Andrew Peace
                            wrote on last edited by
                            #18

                            I hate spacees in code bcause it's a pain to manipulate - hwne youhave to prat about backspacing several times when once would've done if the source had been formatted with tabs. Just my £0.02 :) -- Andrew.

                            1 Reply Last reply
                            0
                            • P Paul Lyons

                              Color me ignorant :confused:! Why are some people so vigorously opposed to tabs in source code? I came accross this statement at someones "MVP" website... "people who insist on using tabs to layout their code (i.e. bozos)".:mad: <-ouch that's harsh!-> What are the advantages of spaces versus the disadvantages of tabs? "Do not go where the path may lead, go instead where there is no path and leave a trail." - Ralph Waldo Emerson

                              X Offline
                              X Offline
                              Xian
                              wrote on last edited by
                              #19

                              If you like a certain tab feel then when you start set your "Tabs are Spaces" if you use Visual Studio, then set it to what you want. Let us say 2, as I do. Then when you are done coding you can go and click Edit->Advanced->Tabify and it will change all of your groups of 2 spaces to tabs (I believe it does all of them, maybe just leading...I dont know). Then when you distribute your code (if you care) then whoever maintains it can see it how they want. That way you don't end up with the "mix" of spaces and tabs that I *ALWAYS* end up with when I dont set tabs to spaces. ;P Plus - I like to open my .cpp files in Notepad from time to time and as we all know the tabs in notepad are 8 wide, and most of my code gets scrolled. That angers me! :mad: Peace! ---- Xian

                              S 1 Reply Last reply
                              0
                              • R realJSOP

                                The problem is when you convert your tabs to spaces, and someone else uses a different tab setting (more or fewer spaces). Alignment problems about. Tabs are better. To hell with those thin-skinned pillow-biters. - Me, 10/03/2001

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

                                Tabs are better. Exactly. Back in the dim dark days of C I used spaces. If I added another if, while, for etc. statement around a block of code it was a pain in the arse indenting using the space key. Now in C++ adding // comments to the front of code has no effect on formatting if I use tabs but screws everything if I am using spaces. If you use any value other than 4 for your tabs you are an idiot. :-D Michael Martin Pegasystems Pty Ltd Australia martm@pegasystems.com +61 413-004-018 "Don't belong. Never join. Think for yourself. Peace" - Victor Stone

                                1 Reply Last reply
                                0
                                • P Paul Lyons

                                  Color me ignorant :confused:! Why are some people so vigorously opposed to tabs in source code? I came accross this statement at someones "MVP" website... "people who insist on using tabs to layout their code (i.e. bozos)".:mad: <-ouch that's harsh!-> What are the advantages of spaces versus the disadvantages of tabs? "Do not go where the path may lead, go instead where there is no path and leave a trail." - Ralph Waldo Emerson

                                  C Offline
                                  C Offline
                                  CodeGuy
                                  wrote on last edited by
                                  #21

                                  I'm surprised no one has mentioned the main problem with tabs ... they may look great on your screen, but they totally wreak havoc with printouts. CodeGuy The WTL newsgroup: 970 members and growing ... http://groups.yahoo.com/group/wtl

                                  1 Reply Last reply
                                  0
                                  • P Paul Lyons

                                    Color me ignorant :confused:! Why are some people so vigorously opposed to tabs in source code? I came accross this statement at someones "MVP" website... "people who insist on using tabs to layout their code (i.e. bozos)".:mad: <-ouch that's harsh!-> What are the advantages of spaces versus the disadvantages of tabs? "Do not go where the path may lead, go instead where there is no path and leave a trail." - Ralph Waldo Emerson

                                    J Offline
                                    J Offline
                                    John Fisher
                                    wrote on last edited by
                                    #22

                                    So,   With all of these wonderful opinions, why hasn't someone already written an editor that treats all whitespace before the start of line as tabs or spaces (depending upon developer preference), and indents things according to developer preference? It could then be capable of saving the files with space/tab settings that match any relevant code guidelines, without the developer having to care about it.   I know there are code formatting tools, but someone's got to have invented an editor that will do that sort of thing at load time, right? John

                                    1 Reply Last reply
                                    0
                                    • P peterchen

                                      The absolute proof for Paul Watson's statement....

                                      P Offline
                                      P Offline
                                      Paul Watson
                                      wrote on last edited by
                                      #23

                                      :-D Exactly, someone could probably make a religious war out of Tabs vs. Spaces. regards, Paul Watson Bluegrass Cape Town, South Africa "The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge "In other words, the developer is dealing with an elephant, the accountant is dealing with a bunny rabbit." by Stan Shannon - 16/10/2001

                                      1 Reply Last reply
                                      0
                                      • P Paul Lyons

                                        Color me ignorant :confused:! Why are some people so vigorously opposed to tabs in source code? I came accross this statement at someones "MVP" website... "people who insist on using tabs to layout their code (i.e. bozos)".:mad: <-ouch that's harsh!-> What are the advantages of spaces versus the disadvantages of tabs? "Do not go where the path may lead, go instead where there is no path and leave a trail." - Ralph Waldo Emerson

                                        P Offline
                                        P Offline
                                        Paul Watson
                                        wrote on last edited by
                                        #24

                                        I vote for tabs. Main reason being that with tabs it is then easy in any professional code editor to set how many "spaces" a tab is equal to. I like to only indent by 1 space, makes my code easy to read as opposed to 4 or 8 spaces. But a fellow developer likes to use 4 spaces for indenting. If I used spaces instead of tabs then my fellow developer would have to stick with my 1-space indenting or change it all himself. CodeGuy says that tabs are bad for printing... well personally the number of times I have printed code vs the number of times I have seen other peoples code onscreen is heavily in the laters favour. So I vote for tabs. You are not ignorant, just butting your head against old standards with no place in our modern days :-D regards, Paul Watson Bluegrass Cape Town, South Africa "The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge "In other words, the developer is dealing with an elephant, the accountant is dealing with a bunny rabbit." by Stan Shannon - 16/10/2001

                                        1 Reply Last reply
                                        0
                                        • X Xian

                                          If you like a certain tab feel then when you start set your "Tabs are Spaces" if you use Visual Studio, then set it to what you want. Let us say 2, as I do. Then when you are done coding you can go and click Edit->Advanced->Tabify and it will change all of your groups of 2 spaces to tabs (I believe it does all of them, maybe just leading...I dont know). Then when you distribute your code (if you care) then whoever maintains it can see it how they want. That way you don't end up with the "mix" of spaces and tabs that I *ALWAYS* end up with when I dont set tabs to spaces. ;P Plus - I like to open my .cpp files in Notepad from time to time and as we all know the tabs in notepad are 8 wide, and most of my code gets scrolled. That angers me! :mad: Peace! ---- Xian

                                          S Offline
                                          S Offline
                                          Simon Capewell
                                          wrote on last edited by
                                          #25

                                          Try replacing notepad with metapad. It's much smaller than wordpad and you can customize the tab size.

                                          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