mdr/scalariform — Issue #40: Feature request: indentation of for loops
Author: fanf
Created: 2011-12-23 11:49:38+00:00
State: open

I like to write for loops in that fashion (well, I like it, but the syntax policy at work force me to do so, too), which is for now the more readable I found:

```scala
for {
step1 <- somecode
longername <- somothercodeWithAblock {
block contents
}
aValue = someCodeForTheValue
otherStep <- if(sometest) {
blablabla
} else {
bidibidi bidi
}
} yield {
some result
}
```
The main indentation rules are:

* all arrows are vertically aligned
* '=' for value assignement is aligned with the '<' of arrow, and a space if left to match the '-' of arrows
* right side of arrows only contains variable names, and so, if the left and side of an arrow span other several line, the block margin start one space after the column of the arrow

For now, that indentation is not easy to achieve naturally, because scalariform really wants to make spanning line starts two * 2 space after the for (even if the workflow was: open '{' at end of line, press enter so that the automatically inserted '}' goes on the next line, align '}' as you want it to be, insert a new line after '{': the cursor is one more time far on the left).

That would be a great feature !