IntelliJ Indenting on Line After Single Line Comment

Viewed 49

IntelliJ IDEA 2021.1 (Ultimate Edition)

Kotlin: 211-1.4.32-release-IJ6693.72

When hitting enter at the end of the single-comment line, in some cases, the next line gets indented:

// Does NOT happen here
|<- cursor lands here after enter
fun something(
    // Does NOT happen here
    |<- cursor lands here after enter
    param: String
) {
    // Does NOT happen here
    |<- cursor lands here after enter
    if (someCondition) {
        // HAPPENS HERE
            |<- cursor lands here after enter
        doOtherThing()
    }
}

I cannot say for sure when, but it seems that this problem started recently.

1 Answers

Go to Settings > Editor > Code Style > Java > Code generation and apply the following settings:

enter image description here

then Settings > Editor > Code Style > Java > Wrapping and Braces and apply the following settings:

enter image description here

Related