auto formatting

82 views
Skip to first unread message

gmseed

unread,
Nov 15, 2012, 12:00:50 PM11/15/12
to scala-i...@googlegroups.com
Hi

I have the follwing block of code:

  test("average of points list") {
 intercept[IllegalArgumentException] {
 // average of empty list should throw exception
 val points = List()
 val averagePoint = Point3D.averagePoint(points)
 }
  }

If I auto format the code by selecting and pressing Ctril+I I get:

  test("average of points list") {
 intercept[IllegalArgumentException] {
 // average of empty list should throw exception
 val points = List()
 val averagePoint = Point3D.averagePoint(points)
 }
  }

Why does it assign a large indent to?:

val averagePoint = Point3D.averagePoint(points)

Thanks

Graham

Luc Bourlier

unread,
Nov 15, 2012, 12:50:08 PM11/15/12
to scala-i...@googlegroups.com
Fun, I didn't even know about this shortcut.

The shortcut you should use to format code in the Scala editor is Ctrl+F (Cmd+F on mac).

Ctrl+I is only supposed to fix the indentation, and it is the implementation for Java, so it doesn't work well with Scala code.

HTH,
Luc

gmseed

unread,
Nov 15, 2012, 4:22:09 PM11/15/12
to scala-i...@googlegroups.com
Hi

Thanks for your reply.

I tried Ctrl+Shift+F and it works. I see that this is the acc. key for the right-click context menu item Source|Format.

I also note that comparing the Java/Scala perspectives the main menu item "Source" doesn't appear in Scala. When in Java the menu item Source|Correct Indentation is Ctrl+I and this should be disabled when in Scala, otherwise it incorrectly indents.

Graham
Reply all
Reply to author
Forward
0 new messages