View Poll Results: How many spaces do you indent your code?

Voters
68. You may not vote on this poll
  • 1 space

    4 5.88%
  • 2 spaces

    21 30.88%
  • 3 spaces

    13 19.12%
  • 4 spaces

    33 48.53%
  • 5 spaces

    7 10.29%
  • 6 spaces

    5 7.35%
  • 7 spaces

    4 5.88%
  • 8 spaces

    8 11.76%
  • Other

    7 10.29%
Multiple Choice Poll.

How far do you indent?

This is a discussion on How far do you indent? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Okay, just curious again: How many spaces do you indent? I indent 4 spaces. I think 4 will be the ...

  1. #1
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048

    How far do you indent?

    Okay, just curious again: How many spaces do you indent? I indent 4 spaces. I think 4 will be the majority.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  2. #2
    C(++)(#)
    Join Date
    Jul 2004
    Posts
    309
    Tab.
    To code is divine

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    never tab unless you have tabs set to insert spaces.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Well, how much does the tab indent in your editor?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    never tab unless you have tabs set to insert spaces.
    You know, I agree. Tabs can really mess up your indentation. But everyone seems to use them.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Registered User
    Join Date
    Aug 2005
    Posts
    91
    I let Dev-C++ indent for me, unless an if statement indents too far, then I set it to about 7. Otherwise, it's 4 or 5. So I selected all three options above.

  7. #7
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    never tab unless you have tabs set to insert spaces.
    If you can manage not to mix the two, tabs are fine. 2 or 3 spaces are not enough. Use 4 or more.

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    You guys are weird. I ALWAYS indent 4 spaces.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  9. #9
    Nonconformist Narf's Avatar
    Join Date
    Aug 2005
    Posts
    174
    2 or 3 spaces are not enough. Use 4 or more.
    My experience doesn't justify this statement. In my opinion, 1 is too little, but 2 is enough if the code is formatted consistently. 4 can easily be too much with some styles of C and most styles of C++ where lines can get pretty long, and the indention doesn't help.
    Just because I don't care doesn't mean I don't understand.

  10. #10
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Does anyone actually indent 1 space?

    I know Govtcheez voted for everything, but I doubt he uses 1 space. Well, maybe.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  11. #11
    Registered User Boomba's Avatar
    Join Date
    Jun 2003
    Posts
    89
    I do a tab, whyd does a tab screw things up?

  12. #12
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Well, if you transfer it, it sometimes ends up looking like this:

    Code:
    int main(void) {
                         if(1) {
                          printf("hi");
                }
                      return 0;
         }
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  13. #13
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    Yup. I use 2. 4 is too much; especially if you have to keep it under 80 char per line, those indents add up quickly.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  14. #14
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    If they "add up quickly", modularize your program (ie, break it up into functions). One of my books suggests that you shouldn't go over three levels of indentation, but I don't go that far.

    But I think 8 is too much, for all that.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  15. #15
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    If your lines are too long it's not the tab size that is the problem.

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weird Strings??
    By Paul22000 in forum C++ Programming
    Replies: 12
    Last Post: 07-14-2008, 01:02 PM
  2. array comparison
    By battoujutsu in forum C Programming
    Replies: 12
    Last Post: 12-05-2003, 10:47 AM
  3. Visual C++
    By Golffor1 in forum C++ Programming
    Replies: 1
    Last Post: 08-04-2003, 04:30 PM
  4. how to indent a file.
    By hakim12 in forum C++ Programming
    Replies: 2
    Last Post: 01-30-2003, 01:55 PM
  5. Indent code
    By boontune in forum C++ Programming
    Replies: 3
    Last Post: 01-23-2003, 10:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21