行注释斜杠的缩进 [英] Indentation of line comments’ slashes

查看:112
本文介绍了行注释斜杠的缩进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用IntelliJ的功能使用行注释注释时,它会在所选行的最开头放置两个斜杠。正斜杠不会与其余代码一起缩进。如何在放置正斜杠时使IntelliJ服从行缩进?

When I use IntelliJ’s function "Comment with Line Comment" it places two slashes at the very beginning of the selected lines. The forward slashes are not indented with the rest of the code. How can I make IntelliJ obey the line indentation when placing the forward slashes?

示例代码:

if (something) {
    bar();
}

在第2行使用IntelliJ的评论功能会导致:

Using IntelliJ’s commenting function on line 2 results in:

if (something) {
//  bar();
}

我想要的是什么:

if (something) {
    // bar();
}


推荐答案

转到文件>设置>编辑>代码风格> Java>代码生成并取消选中在第一列排行注释选项。

Go to File > Settings > Editor > Code Style > Java > Code Generation and uncheck the option "Line comment at first column".

在评论中从@henrebotha更新2016年10月:

Update Oct 2016 from @henrebotha in the comments:


截至目前,在其下方还有一个附加选项,即在评论开始时添加空格,因此现在支持此功能。

As of now, there's an additional option just beneath it that says "Add a space at comment start", so this is now supported.

这篇关于行注释斜杠的缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆