I'm using Eclipse with Scala plugin and every time I do something like
val blah = "test"
And press Enter the IDE automatically indents the following line. I'm wondering if this is a coding convention or some weird IDE quirk.
I'm using Eclipse with Scala plugin and every time I do something like
val blah = "test"
And press Enter the IDE automatically indents the following line. I'm wondering if this is a coding convention or some weird IDE quirk.
It's definitely just a small bug in Scala-IDE. The plugin has a lot of little formatting issues.
However, if you want your life to be awesome then you can hit CTRL+SHIFT+F (CMD+SHIFT+F on mac) and it will automatically format your code and correct those little issues.
EDIT: By the way, it seems there are a couple of tickets out for this issue. See this and this. I added a comment about this precise issue to one of them, so hopefully it's in the queue to get fixed.
Internally, the Scala-IDE uses scalariform https://github.com/mdr/scalariform the scala code formatter. It provides rather limited configurability (IMHO), especially with regard to the placement of curly braces, and with regard to indentation of code blocks. It only supports the scala style standard for curly braces.
A similar problem (auto-indentation of subsequent lines) occurs if the first line of a function value or definition ends with an equals sign (e.g., gnu-style, which is the standard on some of the projects I work on). Here's an example of a gnu-style function def:
def receive =
{
case "ping" => sender ! "pong"
}
Here's what the formatter converts it to:
def receive =
{
case "ping" => sender ! "pong"
}
I haven't found any alternative code formatters, so hopefully scalariform will acquire some added flexibility at some point.
It shouldn't do it unless it is configured in formatting options under Scala -> Formatter