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-studioquestion
51 Posts 26 Posters 0 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 Rein Hillmann

    I know that this is quite a heated debate and I was always on the "Tabs forever" side of the argument but recently I've switched to spaces instead of tabs (due to factors outside of my control) and to be honest, I'm LOVING it. Now I can align all my code the way I like it and not have to worry about the tabs lining up with the parenthesis. What do you guys mostly use? Do your companies have a convention on this?

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

    Geez, flashback to arguments 15yrs ago. At that time the consensus was tabs to the first character in a line, spaces after that. Not that that solves all the problems. Perhaps the argument should be turned from 'tabs vs. spaces', to 'people who don't use 4 spaces per tab stop should be shot'. Personally after having used both systems for years I now use the aforementioned tabs at the start, spaces within. With VS indent/unindent toolbar buttons I find tabs at the start much easier to live with. ...cmk

    1 Reply Last reply
    0
    • R Rein Hillmann

      I know that this is quite a heated debate and I was always on the "Tabs forever" side of the argument but recently I've switched to spaces instead of tabs (due to factors outside of my control) and to be honest, I'm LOVING it. Now I can align all my code the way I like it and not have to worry about the tabs lining up with the parenthesis. What do you guys mostly use? Do your companies have a convention on this?

      L Offline
      L Offline
      LucidCoder
      wrote on last edited by
      #37

      Spaces look great in that everything is layed out just the way the originator intended. The trouble is when you have to maintain a multitude of files that you didn't originally create and they all use a different number of spaces for indenting. You don't want to have to switch your editor's tabs/spaces. Tabs were invented for a reason. They abstractly represent an indentation without forcing a certain appearance on the viewer. Like HTML, beauty is in the eye of the beholder, not the creator. If someone wants to read their news in 16-pt Times Roman Font with double line spacing, they should be able to. Just the same, if someone wants to read your code in a manner that they are more accustomed to and is easier on their eyes, they should have a right. The chief complaint everyone has with tabs is that people mix tabs with spaces to line things up in their editor without realizing that it won't line up in someone else's. This is the true villain here. Whichever you choose, don't mix them up. I personally choose to line up my comments at a certain tab stop, though as there might still be conflicts when text runs past this point, I often don't line up my comments. I put them precisely two spaces after the code. However, on multi-line function headers, I do line up all the parameters on a common tab stop. E.g. void MyFunc1(int param1, int param2, int param3); void MyFunc2( int param1, int param2, int param3); void MyFunc3(int param1, int param2, int param3); Ironically, I had to use spaces to simulate tabs here. :laugh: The bottom line is that consistency is everything. If you use spaces, don't use tabs. If you use tabs, be careful with your spaces. After all, if it's not consistent, how can you call it a style?

      1 Reply Last reply
      0
      • T Taka Muraoka

        In a perfect world, that's perhaps what would happen. In practice, it never does. People often want to lay things out (e.g. in comments) but align on columns that are not at tabstops. So they type TAB TAB SPACE SPACE "xxx". Which ends up unreadable unless you have your tabstops set the same.


        Software is everything. It also sucks. Charles Fishman [^] Awasu 1.0.4 (beta)[^]: A free RSS reader with support for Code Project.

        F Offline
        F Offline
        Fredrik Skog
        wrote on last edited by
        #38

        Taka Muraoka wrote: So they type TAB TAB SPACE SPACE "xxx". Doesn't this imply that people using spaces should be shot? ;P Cheers, Fredrik
        "Felix qui potuit rerum cognoscere causas."

        1 Reply Last reply
        0
        • R Rein Hillmann

          I know that this is quite a heated debate and I was always on the "Tabs forever" side of the argument but recently I've switched to spaces instead of tabs (due to factors outside of my control) and to be honest, I'm LOVING it. Now I can align all my code the way I like it and not have to worry about the tabs lining up with the parenthesis. What do you guys mostly use? Do your companies have a convention on this?

          J Offline
          J Offline
          Jim A Johnson
          wrote on last edited by
          #39

          Tabs until the first non white char; spaces after that.

          1 Reply Last reply
          0
          • R Rein Hillmann

            I know that this is quite a heated debate and I was always on the "Tabs forever" side of the argument but recently I've switched to spaces instead of tabs (due to factors outside of my control) and to be honest, I'm LOVING it. Now I can align all my code the way I like it and not have to worry about the tabs lining up with the parenthesis. What do you guys mostly use? Do your companies have a convention on this?

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

            Spaces. I have an aligmnent fetisch.


            "Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
            sighist | Agile Programming | doxygen

            1 Reply Last reply
            0
            • T Taka Muraoka

              jdunlap wrote: tell us why tabs are so bad. Have you ever had to work on source code written by somebody who had their tab stops set differently to you?


              Software is everything. It also sucks. Charles Fishman [^] Awasu 1.0.4 (beta)[^]: A free RSS reader with support for Code Project.

              S Offline
              S Offline
              Stephane Rodriguez
              wrote on last edited by
              #41

              Select text. Alt+F8. Done.

              1 Reply Last reply
              0
              • T Taka Muraoka

                People who use tabs should be shot!!!


                Software is everything. It also sucks. Charles Fishman [^] Awasu 1.0.4 (beta)[^]: A free RSS reader with support for Code Project.

                D Offline
                D Offline
                David Wulff
                wrote on last edited by
                #42

                The first thing I do when I open a code file that isn't mine is CTRL+A ALT+F8. And if that doesn't catch them all, a quick "Tabify selection" does the trick. :-D So when should I expect to see you?


                David Wulff

                "It is a helpless feeling to be unable to make something so terribly wrong... right."

                T 1 Reply Last reply
                0
                • T Taka Muraoka

                  Don't sweat the petty stuff. Spaces vs. tabs is much more important :-|


                  Software is everything. It also sucks. Charles Fishman [^] Awasu 1.0.4 (beta)[^]: A free RSS reader with support for Code Project.

                  D Offline
                  D Offline
                  David Wulff
                  wrote on last edited by
                  #43

                  Don't sweat the petty stuff and don't pet the sweaty stuff. What is Chris Meech that said that, it rings a bell? :)


                  David Wulff

                  "It is a helpless feeling to be unable to make something so terribly wrong... right."

                  1 Reply Last reply
                  0
                  • T Taka Muraoka

                    jdunlap wrote: I don't want to have to go space-space-space-space for each indent. Virtually every editor on the planet has a switch to insert spaces instead of tabs. jdunlap wrote: Why not use spaces for comments, etc, and then tabs for other indents? Consistency. If you use one of the above-mentioned editors, then you don't have to remember anything.


                    Software is everything. It also sucks. Charles Fishman [^] Awasu 1.0.4 (beta)[^]: A free RSS reader with support for Code Project.

                    D Offline
                    D Offline
                    David Wulff
                    wrote on last edited by
                    #44

                    Taka Muraoka wrote: Virtually every editor on the planet has a switch to insert spaces instead of tabs Yes, but what about backspacing? :rolleyes:


                    David Wulff

                    "It is a helpless feeling to be unable to make something so terribly wrong... right."

                    1 Reply Last reply
                    0
                    • D David Wulff

                      The first thing I do when I open a code file that isn't mine is CTRL+A ALT+F8. And if that doesn't catch them all, a quick "Tabify selection" does the trick. :-D So when should I expect to see you?


                      David Wulff

                      "It is a helpless feeling to be unable to make something so terribly wrong... right."

                      T Offline
                      T Offline
                      Taka Muraoka
                      wrote on last edited by
                      #45

                      David Wulff wrote: The first thing I do when I open a code file that isn't mine is CTRL+A ALT+F8. S.Rod suggested the same thing but this is not the answer. 1) Not everyone uses Visual Studio. I ran into this problem the most when I was working under UNIX. 2) Checking such a file back into source control is a real PITA because it becomes really hard to tell what is a legitimate change and what is tab-fixing. David Wulff wrote: So when should I expect to see you? Any time. Any place. :-|


                      Software is everything. It also sucks. Charles Fishman [^] Awasu 1.0.4 (beta)[^]: A free RSS reader with support for Code Project.

                      1 Reply Last reply
                      0
                      • N Navin

                        Tabs. I just find them easier, especially when arrowing through code (takes less time to go through tabs than it does spaces.) And now that's dictated in our team's coding standard. :-D Although with all the nifty souce formatting tools out there (including what's included in Visual), it doesn't matter as much as it used to... back in the days when taking out a block of code embedded deep in a loop and putting it into its own function meant a day's worth of work deleting all the extra spaces. "When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein

                        R Offline
                        R Offline
                        roel_
                        wrote on last edited by
                        #46

                        Use Ctrl-Arrows to jump word-style. And vi has been able to move blocks of code one indentation (which as we all know is 4 spaces) for almost 30 years now ;P

                        1 Reply Last reply
                        0
                        • T Taka Muraoka

                          jdunlap wrote: tell us why tabs are so bad. Have you ever had to work on source code written by somebody who had their tab stops set differently to you?


                          Software is everything. It also sucks. Charles Fishman [^] Awasu 1.0.4 (beta)[^]: A free RSS reader with support for Code Project.

                          M Offline
                          M Offline
                          markkuk
                          wrote on last edited by
                          #47

                          There's only one correct way to set tabs (every 8 chars), so this isn't a problem. ;P

                          1 Reply Last reply
                          0
                          • R Rein Hillmann

                            I know that this is quite a heated debate and I was always on the "Tabs forever" side of the argument but recently I've switched to spaces instead of tabs (due to factors outside of my control) and to be honest, I'm LOVING it. Now I can align all my code the way I like it and not have to worry about the tabs lining up with the parenthesis. What do you guys mostly use? Do your companies have a convention on this?

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

                            Tabs :) The tigress is here :-D

                            1 Reply Last reply
                            0
                            • R Rein Hillmann

                              I know that this is quite a heated debate and I was always on the "Tabs forever" side of the argument but recently I've switched to spaces instead of tabs (due to factors outside of my control) and to be honest, I'm LOVING it. Now I can align all my code the way I like it and not have to worry about the tabs lining up with the parenthesis. What do you guys mostly use? Do your companies have a convention on this?

                              J Offline
                              J Offline
                              Jorgen Sigvardsson
                              wrote on last edited by
                              #49

                              Tabs of course. If God did not wanted us to use tabs to indent, he would have made Bill remove the Tab-key from the Windows keyboards. That being said, I do admit that I only use Tabs for the leftmost columns. If I ever type in some text after a tab, then I will only use spaces. This way the code will look just fine and dandy in any editor and I am not enforcing my tabsize=4 setting anybody who are tabsize!=4. I'm such a nice guy, really. :-) -- "It's a condition of mental divergence, I find myself on the planet Olgo part of a intellectual elite, prepared to subjugate the barbarian hordes on Pluto, but even though this is a totally convincing reality for me in every way, nevertheless Olgo is actually a construct on my psychee. I am mentally divergent in that I am escaping certain unnamed realities that plague my life here."

                              1 Reply Last reply
                              0
                              • T Taka Muraoka

                                People who use tabs should be shot!!!


                                Software is everything. It also sucks. Charles Fishman [^] Awasu 1.0.4 (beta)[^]: A free RSS reader with support for Code Project.

                                N Offline
                                N Offline
                                Neville Franks
                                wrote on last edited by
                                #50

                                Taka Muraoka wrote: People who use tabs should be shot!!! With a cannon preferably.:-D Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com

                                1 Reply Last reply
                                0
                                • R Robert Little

                                  Spaces. That way I don't have to worry what editor is used, the code will always look the same. --

                                  "The money power of the country will endeavor to prolong its rule by preying upon the prejudices of the people until all wealth is concentrated in a few hands and the Republic destroyed." -- Abraham Lincoln

                                  A Offline
                                  A Offline
                                  Avery Moore
                                  wrote on last edited by
                                  #51

                                  Robert Little wrote: Spaces. That way I don't have to worry what editor is used, the code will always look the same. That's the same reason I use spaces.

                                  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