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.
Comment and uncomment blocks of codeFrom the main menu, select Code | Comment with Block Comment. Press Ctrl+Shift+/ .
You can enable soft wrap for the editor with ⇧⇧ (macOS), or *Shift+Shift (Windows/Linux), for the Search Everywhere dialogue, and then typing in soft wrap. You can also go to Preferences/Settings > Editor > General to enable Soft Wraps for more file types by default.
Add a new commentType /** before a declaration and press Enter . The IDE auto-completes the doc comment for you. For information on how to disable this feature, refer to Disable automatic comments.
Sometimes code formatting can get out of sync, but there's an easy fix in IntelliJ IDEA. You can use ⌘⌥L (macOS), or Ctrl+Alt+L (Windows/Linux) to reformat a selection of code according to your reformat settings.
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.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With