Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 432
Bruce Lowe Avatar asked Oct 30 '13 09:10

Bruce Lowe


People also ask

How do I change the indent spacing in IntelliJ?

Press Ctrl+Alt+S to open the IDE settings and select Editor | Code Style. Select the Detect and use existing file indents for editing checkbox. Apply the changes and close the dialog.

How do I fix indenting in IntelliJ?

If you need to adjust indentation settings, in the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style. On the appropriate language page, on the Tabs and Indents tab, specify the appropriate indents options and click OK.

How do I show indentation in IntelliJ?

Display indent guides To display these lines, open the Settings/Preferences dialog ( ⌘, on macOS or Ctrl+Alt+S on Windows and Linux), go to Appearance and Behavior | Appearance, and enable the Show tree indent guides option.

How do I tab multiple lines in IntelliJ?

[Shift] + [Tab] (to move things further left)


1 Answers

In Idea Intellij 13+

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

  • Label indent: 4

  • Label indent style: Indent statement after label

like image 128
MariuszS Avatar answered Nov 01 '22 23:11

MariuszS