Search code examples
javaintellij-idea

Is there a feature in inteliJ to automatically add a space after '/*' in block comments?


Is there a feature in inteliJ to automatically add a space after '/*' in block comments?

I think having spaces improves readiability, so I'm considering making a change to include them.

The expected result would be something like /* abcd */


Solution

  • Code style settings for generated block comments can be found here:

    enter image description here

    If you enable the highlighted option and then press Ctrl+Shift+/ in the editor to insert a block comment stub, it will include spaces between its opening/closing elements and the content, like this: /* <cursor> */

    I don't believe you can reformat already existing block comments, but you can multi-select them in the editor and then press Ctrl+Shift+/ twice to re-generate the blocks:

    enter image description here

    The action can be also found in the main menu under Code -> Comment with Block Comment