• Forum
  • Lounge
  • What Tab and Indent size do you code wit

 
What Tab and Indent size do you code with?

Feb 13, 2009 at 6:35am
Just wondering as everyone's different. Myself I tab 4 and indent 4 - Programs default.

:)
Feb 13, 2009 at 8:30am
closed account (z05DSL3A)
4 spaces (The IDE is set to replace replace tabs with spaces).

While on the subject of 'style' I also stack my braces, it makes it very quick and easy to see the blocks of code.
eg:
1
2
3
4
5
6
7
8
9
10
11
    if(...)
    {
        if(...)
        {
            ...
        }
    }
    else
    {
        ...
    }

Last edited on Feb 13, 2009 at 8:35am
Feb 13, 2009 at 9:38am
Well my style is the same as yours. I find it looks very neat. I'm not a fan of this though:
1
2
3
4
if(...)
    //Do this
else
    //Do this 


I find this very messy
Feb 13, 2009 at 5:25pm
4 spaces, no tabs allowed! vim can be configured to replace tabs with spaces, as well.

Even on here tabs make the code reach out of the code tags. ;)

I also stack braces. I also do not use if statements without braces (got used to it from my company's coding standards).
Feb 13, 2009 at 9:28pm
@ seymore15074 - You make a good point with
Even on here tabs make the code reach out of the code tags. ;)
Feb 13, 2009 at 11:17pm
4 spaces, tab = 4 spaces as well...for if thens I do this:

1
2
3
4
5
if() {
    //then
} else {
    //else
}
Feb 14, 2009 at 4:16pm
Only tabs, never spaces.
The reason for the former is that if someday I get hit in the head and decide that I want 2 column indentations rather than 4 as I'm using now, I don't need to do a global replace; I just need to configure the editor.
The reason for the latter is that many assume that tab will have some predefined width, so it's not unusual to see something like this:
--tab--> Some text:
--tab-->--tab-->Some other text.
--tab-->--tab-->Some other text.

Which sometimes looks like this:
tab> Some text:
tab>tab>Some other text.
tab>tab>Some other text.


For output indentation, however, I exclusively use spaces.

As for braces, I've always liked (mostly) The One True Brace Style. It's the one I came up with myself (I didn't learn it from the book), so it's the one that feels the most natural to me.
Last edited on Feb 14, 2009 at 11:21pm
Feb 15, 2009 at 4:20am
@firedraco - they are the "if else" I use to do. I use to love them but now I can't handle using them since i changed to:
1
2
3
4
5
6
7
8
if()
{
    //code
}
else
{
    //code
}

Just got to use to this way now and love it :D
Feb 15, 2009 at 8:00pm
2 spaces. All tabs replaced with 2 spaces.
Feb 19, 2009 at 6:15pm
i used to do:

1
2
3
4
5
6
7
8
if()
     {
      //code
     }
else if()
     {
      //code
     }


but now i do

1
2
3
4
5
6
7
8
if()
{
    //code
}
else
{
    //code
}


and i use tabs, and whatever the default is
Topic archived. No new replies allowed.