How do I apply comments at the indent level when toggling them?

When toggling a comment in a PHP document using Code > Comment with Line Comment or pressing Command + /, PhpStorm behaves by:

1. Adding a double forward slash at line position 1 and;
2. Moving the cursor to the next line.

e.g. Result after commenting line 44:

Screenshot on 2013-05-24 at 21.48.25.png

Is there any way I can change this behaviour to:

1. Add a comment at the current indent level and;
2. Leave the cursor where it is?

e.g. I'd prefer if this was the result after commenting line 44:

Screenshot on 2013-05-24 at 21.49.58.png


Hi there,

Is there any way I can change this behaviour to:


Currently you can: invoke "Code | Reformat Code..." on a selection later .. and with appropriate setting (Settings | Code Style | PHP) it will move comment to the same indent level.

I'm not going to comment on what is the correct indent level should be (I personally prefer current behaviour) .. but moving cursor to next line is very logical action as this what is done in vast majority of comment line usage cases.

In any case: (for PHP) and (for JavaScript)


Many thanks for this. I've upvoted the two filed feature requests and will try to get used to the cursor behaviour. (I've moved to PhpStorm from Sublime Text, which leaves the cursor on the same line when toggling a comment.)


Came here while searching for the same functionality.
I prefer it apply comments right before the first line too.
Now I have to write my comments, hit cmd+/ and *ugh....go back and correct the indentation.
Please make it smarter soon.


Its really frustrating to always correct the indentation of comment. I am surprised how Intellij doesn't have this yet since almost all good editors(Sublime) have it. 

+1 for "Please make it smarter soon" :)



Comment indentation for PHP has been fixed 4 years ago, there is an option for that. Similar option exists for JavaScript as well.


@Andriy - Thanks for sharing, yes its available. I recently started using Intellij, doesn't know much about options. I am using Scala and not having options for "Add a space at comment start" , is there a ways to set it for Scala? 


Code formatting is implemented separately for each language. If Scala does not have such option, then it's not yet implemented. perhaps? If not -- feel free to create your own ticket:


Please sign in to leave a comment.