Honestly that's the indentation format I use for every language. Doing it in Lisp just makes sense.
My "OTBS all the things" rules:
- Never horizontal align. Indentation is a simple tree, with each set of children indented 1 layer deeper, which can be 4 spaces or 1 tab.
ThisKindOfThing(
foo,
bar,
baz);
is generally dumb.
- If a block is worth indenting for, the end of the block deserves its own line. Just do OTBS but also for parentheses if you've a long function call.
ThisKindOfThing (
foo,
bar,
baz
);
Is just more consistent and easier to manage while still being legible.
- if you're ever splitting something across multiple lines there must be an indent.
myObj
.Foo()
.Bar()
.Baz();
- you're allowed to double-dip on tree depth - that is indent only one level for like 3 levels of tree, as long as the opening of that 3-deep jump is a clear one-liner and the end of it is a line that says ")))".
Foo(Bar(Baz(
someVal
)));
- when splitting lines on infix operators, anything but commas go at the start of the line (also, bedmas counts as tree depth)
This is exactly the set of rules I happen to have ended up using. I suspect this is one of the few styles that you inevitably arrive at if you search the space for a format that looks okay, is easy to read, doesn't cause things to shift around when functions are renamed, and is relatively simple and self-consistent.
This is mostly how I indent my code. I don't know why so many people hate it. We have huge screens and spacing conveys structure so I use spacing when appropriate, like a ')' in its own line. I work in a *very* small team though and I write most of the code.
My "OTBS all the things" rules:
- Never horizontal align. Indentation is a simple tree, with each set of children indented 1 layer deeper, which can be 4 spaces or 1 tab.
is generally dumb.- If a block is worth indenting for, the end of the block deserves its own line. Just do OTBS but also for parentheses if you've a long function call.
Is just more consistent and easier to manage while still being legible.- if you're ever splitting something across multiple lines there must be an indent.
- you're allowed to double-dip on tree depth - that is indent only one level for like 3 levels of tree, as long as the opening of that 3-deep jump is a clear one-liner and the end of it is a line that says ")))". - when splitting lines on infix operators, anything but commas go at the start of the line (also, bedmas counts as tree depth)