Solved Indentation style - am I reading this right?

I’ve always been under the impression that mixing tabs and spaces kills puppies, but the style guide for FreeBSD style(9), OpenBSD and others says:

Code:
Indentation is an 8 character tab.     Second    level indents are four spaces.

I’ve been awake all night because of this one line! Am I reading this right? A tab character for the first level, then four spaces thereafter. That’s obviously what it says.
I’ve always used expandtab in Vim to insert spaces with the tab key as not to repeatedly mash the spacebar. Is there a way to configure Vim to insert tabs and spaces in the correct places? My fiddling with things like tabstop and shiftwidth hasn’t been very effective. Maybe it will all be clear after sleep and coffee.
 
Why don't you consult the source code itself? As far as I could see, it's tabs for indicating lexical scope and spaces for expressions split into multiple lines.
 
Why don't you consult the source code itself? As far as I could see, it's tabs for indicating lexical scope and spaces for expressions split into multiple lines.

Thanks. I had looked at some source code examples prior to posting, but my Vim settings were messing with the way it appears and, in my sleep deprived state, I wasn’t thinking clearly enough to just open a different editor like ee. Also, I was not aware until today of Vim’s :retab command, which is what seems to have been needed to make my changes take effect.

I’m not the brightest bulb, but I’m trying.
 
Check the example right below it and it will all make sense:

Code:
             while (cnt < 20 && this_variable_name_is_too_long &&
                 ep != NULL)
                     z = a + really + long + statement + that + needs +
                         two + lines + gets + indented + four + spaces +
                         on + the + second + and + subsequent + lines;
while is obviously tab indented whereas the next line uses tab + 4 spaces. The next level of indentation uses 2 tabs. It makes perfect sense too because this way they can use 4 levels of indentation while they would only be able to effectively use 2 if they only relied on tabs.

Don't think in absolutes: use the best tool (or solution) for the job. In this case that is a tab for a quick 1st level indentation, then spaces for the next level because it helps to condense your code.
 
I’ve always been under the impression that mixing tabs and spaces kills puppies, but the style guide for FreeBSD style(9), OpenBSD and others says:

Code:
Indentation is an 8 character tab.     Second    level indents are four spaces.

I’ve been awake all night because of this one line! Am I reading this right? A tab character for the first level, then four spaces thereafter. That’s obviously what it says.
I’ve always used expandtab in Vim to insert spaces with the tab key as not to repeatedly mash the spacebar. Is there a way to configure Vim to insert tabs and spaces in the correct places? My fiddling with things like tabstop and shiftwidth hasn’t been very effective. Maybe it will all be clear after sleep and coffee.

Yes. This line causes me to grind my teeth as well, and to bite my tongue rather than get into a no-winner debate about coding styles.
 
Back
Top