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.

Thread: How far do you indent?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057

    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,057
    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,057
    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
    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.

  9. #9
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    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.

  10. #10
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    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,057
    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
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Quote Originally Posted by dwks
    Well, if you transfer it, it sometimes ends up looking like this:

    Code:
    int main(void) {
                         if(1) {
                          printf("hi");
                }
                      return 0;
         }
    Stop using the Kernel style then, Allman all the way!
    Also, don't mix spaces with tabs. Use one or the other, not both.

    I use 3 or 4, whatever is standard in VC2003.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  14. #14
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Coding standards at your house will decide. Left to me 4 spaces.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  15. #15
    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

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, 11: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, 02:55 PM
  5. Indent code
    By boontune in forum C++ Programming
    Replies: 3
    Last Post: 01-23-2003, 11:27 AM