11

In recent versions of Intellij IDEA, when writing a scala method which returns Unit(a.k.a. a procedure), IDEA will fold the : Unit = part, so that it displays like the so-called "procedure syntax". Here's what it looks like :

def myMethod(): Unit = {
  // do something
}

gets folded by default to :

def myMethod()  {
  // do something
}

I understand the point, since the procedure syntax is slated for deprecation but some people still like it, I guess it's a good compromise for them. However, for those of us who don't like the procedure syntax, I wasn't able to find a setting to disable that code folding by default. Preferences > Editor > Code folding does show some scala-specific settings for which code foldings should be collapsed by default, but the only one I have checked is "Shell comments (scala script)".

Does someone know how to disable this feature? Or is it currently impossible?

Cyäegha
  • 4,191
  • 2
  • 20
  • 36
  • possible duplicate of [How to turn off Scala auto-completion of function with Unit return type in IntelliJ IDEA?](http://stackoverflow.com/questions/25468047/how-to-turn-off-scala-auto-completion-of-function-with-unit-return-type-in-intel) – Andrey Mar 11 '15 at 23:47
  • No duplicate there - my question is about the way code is displayed (no impact on the actual source code written to the file), the question you link to is about auto-complete of the actual code. Edit: didn't remember asking about display issues in the comments - but still a different question IMO. – Cyäegha Mar 12 '15 at 08:41

1 Answers1

11

It's in Preferences -> code style -> Scala, then on the right there are two hidden tabs, go on other and there should be a check with Enforce procedural syntax for methods with Unit return type

enter image description here

For Intellij 14 the path is slightly different:

enter image description here

Ende Neu
  • 15,581
  • 5
  • 57
  • 68
  • Thanks, that did the trick! I didn't think to look in "Code Style": I would have thought it was only for settings which modify the actual source code when auto-formatting, rather than just changing how it's displayed like in this case. – Cyäegha Aug 27 '14 at 22:27
  • 1
    And usually it's like that (PHP, JS, SQL and many others) the Scala and Java plugin seems to be an exception for many cases. – Ende Neu Aug 27 '14 at 22:29