Short version
When pressing <enter>
at the end of a //
comment, Intellij sometimes decides to continue the //
comment on the next line. How can I prevent that? Is there a setting somewhere to disable this automation?
Long version
There is a thing I do regularily, it is to break a long expression with a double-slash.
Let's say I have a line like
boolean isHex = c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f';
and I want to split it like that
boolean isHex = c >= '0' && c <= '9' //
|| c >= 'A' && c <= 'F' //
|| c >= 'a' && c <= 'f';
Note that I want the final //
in order to prevent any formatter to join the lines again.
So I insert a double-slash-return after the '9'
, by pressing //<enter>
. But Intellij will auto-continue the comment on the next line.
boolean isHex = c >= '0' && c <= '9' //
// || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f';
It forces me to uncomment and reindent the line manually.
I want Intellij to not continue the comment on the next line and optionally indent my code:
boolean isHex = c >= '0' && c <= '9' //
|| c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f';
So I want to disable this "continue // comment after <enter>
" feature. Is it possible? I haven't found any setting related to that.
To add or remove a block comment, do one of the following: From the main menu, select Code | Comment with Block Comment. Press Ctrl+Shift+/ .
The closest you are going to get is to define a macro to insert a new line and remove the comment and then bind that macro to a suitable key.
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