Android Code Style for Comments

I am writing code for some of our Android projects. I would like to facilitate this by using Android Studio's Code Style Preferences. I almost followed the options settings: Android Studio-> Preferences-> Editor-> Code Style-> Java.

One thing I'm missing is that we want the comments to be formatted like this:

// a useful comment

      

Instead:

//a useful comment

      

How to tell Android Studio but the space between the forward slash and the text in a comment? Thank!

+3


source to share


3 answers


If you hit CTRL /

or CMD /

, it will place //

at the beginning of the line and the comment will be indented correctly.

//        comment with two indents

      

This needs to be done Comment at first column

in Editor->CodeStyle->Java->Wrapping and Braces->Keep when reformatting

as mentioned in the other answer.



screenshot

If you want to write a multi-line comment, you can use CTRL SHIFT /

or CMD SHIFT /

This way, when you enter a new line, you will have one place after the start of the comment

    /*
    * there is space before this*/

      

+2


source


You can do this under the Wrapping and Braces tab.



0


source


I just solved this problem.

I think you can find Code Style -> Java -> Code Generation
Exists Comment Code

and select Add a space at comment start


I think your problem can be solved.

0


source







All Articles