Reputation: 552
Now, I am using the default configurations, and the "//" is displayed at the first column when I press the "command" + "/", see the second line in the picture.
How can I change configuration to display the "//" at the start of the code and following with a space? Just like the first line.
Upvotes: 44
Views: 14476
Reputation: 110
To fix comments during reformatting, go to file->settings->editor->code style->java->wrapping and braces->keep when reformatting->uncheck "comment at first column"
Upvotes: 0
Reputation: 10634
There is an option in: Code Style > Java > Code Generation > Comment Code
With "Line comment at first column" you can switch between:
//System.out.println("");
// System.out.println("");
So, you don't have a 'space' after comment (in first line), but its close enough :)
Recent versions of IntelliJ IDEA support adding a space after the line comment. The setting is at the same location.
Upvotes: 72
Reputation: 1570
IntelliJ 2017.2 now does exactly what you want. I'm not sure when this was originally introduced.
Project Settings > Code Style > Java
Change tab to Code Generation, locate Comment Code section
Uncheck "Line Comment at First Column"
Check "Add a space at comment start"
Now when you press Control-/
boolean goodCode = true;
becomes
// boolean goodCode = true;
Upvotes: 1