Reputation: 1218
I'm writing code guidelines for some of our projects on Android. I'd actually like to facilitate this by using Android Studio code style preferences. I'm almost done setting parameters there: Android Studio->Preferences->Editor->Code Style->Java.
One thing I'm missing is that we want comments to be formatted like this :
// a useful comment
Instead of :
//a useful comment
How do I tell Android Studio to but a space between slashes and the text in the comment? Thanks!
Upvotes: 7
Views: 2898
Reputation: 1018
For anyone who doesn't know
Under Code Style → Java/Kotlin→Code generation
Uncheck Line comment at first column
Check Add a space at line comment start, then Enforce on reformat
It should be okay
Upvotes: 0
Reputation: 356
I have just solved this problem.
I think you can find Code Style -> Java -> Code Generation
There is a Comment Code
and select the Add a space at comment start
I think your problem can be solved.
Upvotes: 1
Reputation: 31361
If you press CTRL /
or CMD /
it will put //
at the beginning of the line and the comment will be properly indented.
// comment with two indents
For this to work Comment at first column
must be checked in Editor->CodeStyle->Java->Wrapping and Braces->Keep when reformatting
like mentioned in another answer.
If you want to write multiline comment you can use CTRL SHIFT /
or CMD SHIFT /
That way when you go into new line, you will have one space after the comment start
/*
* there is space before this*/
Upvotes: 2