Bruce Lowe
Bruce Lowe

Reputation: 6213

Indenting / Spaces layout after a label in Intellij with groovy

Intellij Seems to have a default layout like this

def foo(int arg) {
    label1:
    for (i in 1..10) {
        label2:
        foo(i)
    }
}

How do i change it to

def foo(int arg) {
    label1:
        for (i in 1..10) {
            label2:
            foo(i)
        }
}

This is required since we want out test layouts to look like this:

def 'my test'() {
   given:
       ...
   when:
       ...
   then:
       ...
}

ANSWER: As given below in the answer, I can confirm this works in intellij 13

Upvotes: 16

Views: 4297

Answers (2)

DevTomek
DevTomek

Reputation: 653

Screenshot from IntelliJ IDEA 2022.2.4 enter image description here

Upvotes: 0

MariuszS
MariuszS

Reputation: 31597

In Idea Intellij 13+

Settings -> Editor -> Code Style -> Groovy -> Tabs and Indents

  • Label indent: 4

  • Label indent style: Indent statement after label

Upvotes: 38

Related Questions