Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indentation of line comments’ slashes

When I use IntelliJ’s function “Comment with Line Comment” it places two slashes at the very beginning of the selected lines. The forward slashes are not indented with the rest of the code. How can I make IntelliJ obey the line indentation when placing the forward slashes?

Example code:

if (something) {
    bar();
}

Using IntelliJ’s commenting function on line 2 results in:

if (something) {
//  bar();
}

What I want:

if (something) {
    // bar();
}
like image 827
Christian Siegert Avatar asked Sep 02 '15 00:09

Christian Siegert


2 Answers

Go to File > Settings > Editor > Code Style > Java > Code Generation and uncheck the option "Line comment at first column".

Update Oct 2016 from @henrebotha in the comments:

As of now, there's an additional option just beneath it that says "Add a space at comment start", so this is now supported.

like image 186
Zarwan Avatar answered Oct 24 '22 01:10

Zarwan


You can setup in Code Generation: Options

like image 11
cwtuan Avatar answered Oct 23 '22 23:10

cwtuan