Search code examples
groovyintellij-idea

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


Solution

  • In Idea Intellij 13+

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

    • Label indent: 4

    • Label indent style: Indent statement after label