View Poll Results: Do you like editors that default to tabs or to spaces?

Voters
40. You may not vote on this poll
  • Go tabs!

    18 45.00%
  • Go spaces!

    22 55.00%

Thread: Tabs or Spaces

  1. #16
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >See my above posts...especially the case study above.

    the case study is a user error, not a problem with the number of spaces representing a tab. If you open the python file in a new editor and your 2 indents line up wrong, you should re-indent the file, or change your editor preferences to be consistent.


    all spaces, all the time

  2. #17
    Registered User divineleft's Avatar
    Join Date
    Jul 2006
    Posts
    158
    tabs

    it's horribly impracticable to press the space bar 4 times when you can just press tab. same applies to deleting things from lines.

    and if portability is such an issue, just change the tab width to meet your requirements.

    i don't post very much code on forums, and when I do, it is mostly example code that I write right then and there. i'm not uploading files or anything. if i ever had to do something like that and the spacing was messed up, I would just make a short script or c program to change tabs into spaces.

  3. #18
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    "Spaces by default" represents about half a dozen standards, each of which is inconsistent with each other...
    You're right. To be absolutely consistent such a standard has to define a number of spaces per indent level, similiar to the recommendation in Python's PEP 8 document. Of course, the difference is still clear from the start, as when you try to indent, you would immediately notice that the indent level is inconsistent with the original code.

    "Tabs by default" is unambiguous, and lets different programmers choose their amount of indenting without physically modifying the entire source.
    I liked that reasoning, but when I discovered "x characters per line" limits due to printing and screen line limits, I realised that the choice is not always there. Changing the indent size of a tab can break such guidelines, and one also has to consider the printer settings if the code is to be printed. You really do have to follow the convention set out in the original code, or else just re-format everything.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #19
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Tabs. Something just irritates me about trying to delete a tab character by pressing backspace only to find out that the tab is actually multiple spaces.

  5. #20
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Spaces. I didn't care the begin with, but after a few hundred buggered forum-posts, I turned into a space-man.
    EDIT:
    >> Tabs. Something just irritates me about trying to delete a tab character by pressing backspace only to find out that the tab is actually multiple spaces.

    I do see your point about that though, especially since I just upped my indentation level from 2 to 4 spaces. Maybe I should become tab-man again.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  6. #21
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    Tab-man.

    Actually, I usually cheat. If I brace everything fully, the IDE will indent with spaces automagically. So I guess my indenting style is braces.

    I would think though that if you were working on a serious project, that these sort of guidelines are hammered out and you're required to do it that way. I've also recently decided that stuff like
    Code:
    std::transform(a.begin(), a.end(),
                   b.begin(),
                   foo());
    is just not worth it. I don't need it to be that neat and I don't try to. You'd have to make me.
    And I wonder, why is a.begin() and a.end() on one line? [/rhetoric]

  7. #22
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    Up until very recently I was a tabber all the way (though I also open and close scope at the start and let the ol' IDE do most of the magic for me), but then I decided to change from tabs to spaces which I prefer. The only problem is using old code and new code and the tab-space mix ups :/ meh. Hopefully someone will be gracious and suggest a good fix for me ...

  8. #23
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    With many people working on the same source files, I found that tabs was far superior to spaces. Different people like different indentation widths. I used to like spaces more, but now I've come to my senses.
    Last edited by Sang-drax; 04-05-2007 at 04:34 PM.

  9. #24
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >it's horribly impracticable to press the space bar 4 times when you can just press tab

    erm, we're talking about editors that place x number of spaces in the file when you push the tab key.

    >>> Tabs. Something just irritates me about trying to delete a tab character by pressing backspace only to find out that the tab is actually multiple spaces.

    A good editor will take care of the indenting for you, in emacs for example, you can push the tab key with your cursor in any position on the line and it will properly indent the line. No need to explicitly add/delete tabs or spaces.

  10. #25
    Registered User divineleft's Avatar
    Join Date
    Jul 2006
    Posts
    158
    lol

    emacs

  11. #26
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by DavidP View Post
    I would have to say that one of my biggest pet peeves in programming is when I use a text editor or an IDE that defaults to inserting "tabs" by inserting a certain number of spaces, instead of inserting an actual tab character. It is incredibly annoying.
    Consider using a beautifier. Then you can write in a relatively sloppy manner, and if it's as simple as a toolbar button (it is my case), then click it every couple lines or so to make everything not only pretty but consistent.

    Quote Originally Posted by Perspective View Post
    >it's horribly impracticable to press the space bar 4 times when you can just press tab

    erm, we're talking about editors that place x number of spaces in the file when you push the tab key.

    >>> Tabs. Something just irritates me about trying to delete a tab character by pressing backspace only to find out that the tab is actually multiple spaces.

    A good editor will take care of the indenting for you, in emacs for example, you can push the tab key with your cursor in any position on the line and it will properly indent the line. No need to explicitly add/delete tabs or spaces.
    Echo that.

    [edit]And spaces, by the way. Three or four.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  12. #27
    Moderately Rabid Decrypt's Avatar
    Join Date
    Feb 2005
    Location
    Milwaukee, WI, USA
    Posts
    300
    Spaces FTW. 3 of 'em.

    I'll admit I didn't read every one of DavidP's posts, but I totally agree with this:
    Quote Originally Posted by Daved
    Putting spaces means that the code will line up the same everywhere you go.
    I use Code::Blocks at home for the most part, pico (I don't know why I love pico when I could use emacs instead, it makes no sense at all), and notepad at work. Going between the three is easy easy easy since I have Code::Blocks convert tabs to spaces. That way it's always the same.

    That said, if you're going between editors that are "good" (as defined above), it probably doesn't matter as much.
    There is a difference between tedious and difficult.

  13. #28
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Spaces.

    Tabs destroys your code in any other editor. Spaces are universal and every editor should know what spaces are and how many to use. Tabs are relative to the app and settings in the editor displaying the document.

    And besides, cprog totally obliterates any source code that uses tabs instead of spaces.

  14. #29
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    is just not worth it. I don't need it to be that neat and I don't try to. You'd have to make me.
    As you noted, it ultimately depends on the coding standards of the project that you are working on, or the company that you are working for.

    And I wonder, why is a.begin() and a.end() on one line? [/rhetoric]
    That is a visual indicator that they are actually one argument (a range) divided into two (the start and end of the range).
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #30
    Lean Mean Coding Machine KONI's Avatar
    Join Date
    Mar 2007
    Location
    Luxembourg, Europe
    Posts
    444
    Probably every major Coding Standard guide I found recommends using 4 spaces instead of tabs, just like the Pear PHP Coding Standards Guide:

    Use an indent of 4 spaces, with no tabs. This helps to avoid problems with diffs, patches, CVS history and annotations.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Changing 3 spaces to tabs
    By dnguyen1022 in forum C Programming
    Replies: 2
    Last Post: 12-22-2008, 12:51 AM
  2. Handling spaces in command line arguments
    By starkhorn in forum C++ Programming
    Replies: 7
    Last Post: 11-16-2004, 02:42 PM
  3. Replies: 5
    Last Post: 06-30-2003, 12:52 PM
  4. tabs to spaces with dev c++ v.4
    By stallion in forum Windows Programming
    Replies: 2
    Last Post: 01-28-2003, 02:07 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM