首页 > 解决方案 > Intellij IDEA Kotlin - 如何在同一列中发表评论?

问题描述

我希望在使用时有注释Ctrl+/,它适用于代码Java 但不适用于 Kotlin代码,我已经按照帮助台中的说明完成了(注意:我正在使用Intellij Ultimate 2018.2

要在 Java 中配置注释行为的设置,请使用注释代码部分中的选项,位于文件 | 中的代码生成选项卡上。设置/首选项 | 编辑 | 代码风格 | 爪哇。

标记Add a space at comment startCommented Code部分,我在里面找不到任何注释代码配置Kotlin Code Style

在此处输入图像描述

例如在Kotlin

fun main(args: Array<String>) {
    // Desired comment
//    After Using Ctrl+/
}

但适用于Java

public class Sample {
    public static void main(String[] args) {
        // Works fine using Ctrl+/
    }
}

标签: javaintellij-ideakotlincomments

解决方案


Wrapping and Braces使用键盘快捷键时此选项对我不起作用,设置如下:

Editor -> Code Style -> Kotlin -> Code Generation

并取消勾选选项:Line comment at first column,完成!


推荐阅读