如何为注释行应用缩进设置(IntelliJ IDEA / Android Studio)

How to apply indentations settings for comment line (IntelliJ IDEA / Android Studio)

我当然知道如何使用行注释快捷方式,ctrl + /,但出于某种原因,注释从行尾开始。

如果我从这段代码开始:

if (something) {
    return 5;
}

并使用 IntelliJ 的快捷方式,我最终得到:

if (something) {
//    return 5;
}

但我希望事情看起来像这样:

if (something)
    // return 5;
}

有什么方法可以在 IntelliJ 中进行配置吗?我尝试更改目标语言的代码语法规则,但没有任何改变。

此设置可以在 (Settings / Preferences -> Editor -> Code Style -> Java -> Code Generation)

中更改

选项:

  • Line comment at first column.

  • Block comment at first column.

它应该适用于 Android Studio 和 IntelliJ IDEA。