Bruce Phillips
Bruce Phillips

Reputation: 2790

How To Set Format Of Multiline Comment in IntelliJ

By default IntelliJ is formatting multiline comment as

/*
A multi line comment
Line 2
*/

I would like it to format the multiline comment as

   /*
    * A multi line comment
    * Line 2
    *
    */

to match the code style standard used by other developers who use Eclipse on my team.

I've combed through the Settings Java Code but cannot find a way to force IntelliJ to automatically put an * at the beginning of each line in the multiline comment.

Thank you for the help.

Upvotes: 5

Views: 4113

Answers (2)

Venkatesan Muniappan
Venkatesan Muniappan

Reputation: 447

We can achieve the same with /** + Enter.

Source

Upvotes: 3

hce
hce

Reputation: 1167

It seems that comments in the copyright section are commented by default the way you would like it.

But you can do the same with your comments by using live templates. Just follow this steps...

Define your Live Template

  • File > Settings (Ctrl + Alt + S on Windows)
  • Editor > Live Templates
  • Add a new one or edit an existing one, like 'sbc' (block comment)
  • Edit the Teplate Text like in the following picture

enter image description here

Use the Live Template

Now if you type sbc in your code

enter image description here

You can expand it to

enter image description here

And with Enter, you can add more commenting lines

enter image description here

Upvotes: 4

Related Questions