Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij IDEA Kotlin - How to comment in same column?

I want comments to be intended when using Ctrl+/, it works for Java but not for Kotlin code, I have done as mentioned in help-desk (Note: I'm using Intellij Ultimate 2018.2)

To configure settings for commenting behavior in Java, use options in the Comment Code section, on the Code Generation tab located in File | Settings/Preferences | Editor | Code Style | Java.

Marked Add a space at comment start in Commented Code section, I couldn't find any comment code configuration in Kotlin Code Style

enter image description here

For example in Kotlin:

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

But works in Java:

public class Sample {
    public static void main(String[] args) {
        // Works fine using Ctrl+/
    }
}
like image 859
Dennis Vash Avatar asked Jul 28 '18 20:07

Dennis Vash


1 Answers

I'm using IntelliJ IDEA 2018.3, but I believe this is still available in IDEA 2018.2.

In Settings, Editor -> Code Style -> Kotlin -> Wrapping and Braces, under Keep when reformatting, untick Comment at first column.

Comment at first column is closed, and the sample shows what we expected.

Update: I found this is not at coding... But take place after Code -> Reformat Code :-(

like image 165
Geno Chen Avatar answered Sep 26 '22 15:09

Geno Chen