Zsolt Z.
Zsolt Z.

Reputation: 599

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

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.

Upvotes: 5

Views: 1517

Answers (2)

Hoda
Hoda

Reputation: 116

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.

Upvotes: 10

Juan G Carmona
Juan G Carmona

Reputation: 2208

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.

Upvotes: 0

Related Questions