简体   繁体   中英

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

I certainly know how to use the line comment shortcut, ctrl + / , but for some reason the comment starts at the end of line.

If I start with this code:

if (something) {
    return 5;
}

And use the shortcut from IntelliJ, I end up with:

if (something) {
//    return 5;
}

But I expect things to look like this:

if (something)
    // return 5;
}

Is there any way to configure this in IntelliJ? I tried changing the code syntax rules for my target language, but it didn't change anything.

This setting can be changed in (Settings / Preferences -> Editor -> Code Style -> Java -> Code Generation)

Options:

  • Line comment at first column.

  • Block comment at first column.

It should work both for Android Studio and IntelliJ IDEA.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM