In IDEA, how to add a space between code & comment automatically?

Eric Wang :

Example

Example A:

T result = (T) node.value; // keep return value,

There is a space between ; and //

Example B:

if (k < 0 || k > size) // out of range,
    return false;

There is a space between ) and //.

Example C:

if (size == 0 || k == size) { // append at end,
    append(value);
    return true;
}

There is a space between { and //.


I searched on Google, and found this post: Is there any way to have the line comment shortcut add a space after // in WebStorm?

The link only tells how to add a space after //, and that's the default behavior.

I didn't found any solution.


Question

  • How to let IDEA add spaces from the above examples automatically on formatting?

(BTW, I am not saying that it's better, I just personally prefer to that, and trying to get it done.)


@Update - issue request created on Jetbrains

A new issue is created on Jetbrains's youtrack for this feature: Provide option to add a space between code and "//" on formatting.

Please up vote it if you also desire for this feature.

CrazyCoder :

There is no option to add the space between the code and the start of the comment in IntelliJ IDEA.

Feature request to track the progress:

  • IDEA-207008 Provide option to add a space between code and "//" on formatting.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=101360&siteId=1