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.
// @formatter:off
/// @formatter:on
comments (search the settings forEnable formatter markers in comments
) – Twibill//
in front of it)? For example, you could just simply break line first and then add the//
at the end of the line or add the@formatter:off
annotation.... (which these unique, personal use-cases are for) - I am not sure the IDE is meant to read our minds (yet ;) ) – Dim