Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do i reformat java comments, to remove whitespaces in intellij?

What IntelliJ format setting should be set to automatically change line comments to look like:

    validcode();
    // comment1
    // comment2
    validCode();

from lookin like this:

    validcode();
    //       comment1
    //       comment2
    validCode();

No result with all the settings i have tried.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

There may be a way to do this via editor settings. But you could remedy this using a regex replace all:

Find:    //\s{2,}(.*)$
Replace: // $1

This would be under the assumption that once a // style comment has been declared, the remainder of that line belongs to the comment.

Note that you could even apply the above replacement to all files in the project, or all Java source files in the project, module, etc.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading