Of braces and parentheses

In Scala, you may often want to replace braces with parentheses and vice versa.

For example, imagine that you decided to use curly braces in the following statement:

It looks like not a big deal, but in practice it takes a lot of key presses, cursor positioning, and a fight with the automatic brace balancing. That’s now a thing of the past.

Just invoke an intention (Ctrl + Alt + Enter):

… and it’s done:

It’s possible to run it the other way:


Besides sequence comprehensions, there are similar intentions for converting method call arguments, like the following:

Run the intention:

The result:

Now let’s transform the braces back to parentheses:

Here they are:

About Pavel Fatin

Programming enthusiast, technology advocate. IntelliJ Scala plugin developer at JetBrains, https://pavelfatin.com
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Of braces and parentheses

  1. Jem says:

    Is nice!

    Is it possible to convert to squirlies but keep the content inline? i.e.

    list.foreach(println) becomes list.foreach{println}

Leave a Reply

Your email address will not be published. Required fields are marked *