How to auto-format whitespaces in comments using android studio?
Asked Answered
B

2

5

My problem is, when I comment out a line using Ctrl + /,

//        comment

and then auto-format the code,

        //        comment

the comment will still contain whitespaces after the "//" that I wouldn't want to keep.

I've already checked the Settings>Editor>Java>Wrapping and Braces options, and also the other tabs.

Thanks in advance.

Bijou answered 20/8, 2015 at 9:11 Comment(0)
J
10

I have just solved this problem.

Code Style -> Java -> Code Generation

There is a "Comment Code" and deselect the "Line comment at first column"

Code Style -> Java -> Wrapping and Braces

There is a "Keep when reformatting" and deselect the "Comment at first column"

As follows

Code Generation

Wrapping and Braces

I think your problem can be solved.

Jemy answered 25/11, 2016 at 2:28 Comment(1)
Not work in the version, Chipmunk|2021.2.1 Patch1Dipteran
H
0

To apply identation to a document press Ctrl + Alt + L (Option + Command + L in Mac)

But the only way, once you have few comments with that "problem", I guess is to replace ('// ' by '//') (Shortcut to replace: Ctrl + Shift + R)

Hope it hepls.

Heyduck answered 20/8, 2015 at 9:57 Comment(1)
I mean '// (few spaces or tbas here)' by '//'Heyduck

© 2022 - 2024 — McMap. All rights reserved.