Re: Indention - why spaces?

Larry McVoy (
Mon, 30 Dec 2002 22:04:59 -0800

On Tue, Dec 31, 2002 at 12:28:37AM -0500, Pete Zaitcev wrote:
> > IMHO and in my personal projects I use the following indenting rules:
> >
> > 1) use TABs for _indentation_
> > 2) use SPACEs for aligning
> >
> > here is an exaple:
> >
> ><tab><tab>if (cond) {
> ><tab><tab><tab>dosometing;
> ><tab><tab><tab>printf("This is foo: '%s', and this bar: '%d'",
> ><tab><tab><tab> foo, bar);
> BTW, this practice is codified in Solaris developer's guidelines.
> They even have a perl script called "hdrchk" which is run before
> commits and tells about violations. Actually, the Sun requirement
> is to have exactly 4 spaces, but it sounds a little too anal to me.

Indeed and the reasoning is that tabs are for indentation, 4 spaces are
for continuation lines.

if (expr) {
if (really_long_expression && another_expression &&
one_more) {

You can do slightly better than that if you do it like this:

if (really_long_expression &&
another_expression && one_more) {
I try and get people to put the longer part of the expression on the
continuation line, your eyes will parse that better than the first way.

By the way, this sort of thing is a big deal around here, I spend a
lot of time getting people to do it all the same way. It's worth it.

The bottom line is "can I fix bugs in your code quickly?". Indentation
is part of understanding the code.

Larry McVoy            	 lm at  
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at