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

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

问题描述

当我使用 IntelliJ 的Comment with Line Comment"函数时,它会在所选行的最开头放置两个斜杠.正斜杠不与代码的其余部分缩进.放置正斜杠时如何让 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();
}

推荐答案

转到 File >设置 >编辑器代码风格爪哇>代码生成并取消选中第一列行注释"选项.

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天全站免登陆