How to configure spacing after line comment (//)?

 In PhpDoc comments, PhpStorm automatically places a space after the leading asterisk when you press enter and it automatically continues the comment.

For example, assume the following.  The underscore represents the cursor.

/**

 * Foo._

 /*

Press enter and the result is:

/**

 * Foo.

 * _

 /*

With line comments, pressing enter at the end of the line doesn't continue the comment.  But if there are characters after the cursor, it does continue the comment.

// Foo_.

Press enter:

// Foo

//_.

Notice that no space is automatically inserted after the // and before the cursor.

Is it possible to configure this?  I don't see anything relevant in Settings -> Editor -> Code Style -> PHP.

 

8 comments
Comment actions Permalink

Did you try Settings|Code Style|PHP|Other|Comment Code, "Add a space at comment start"?

3
Comment actions Permalink

I didn't notice that option because it's strangely disabled if "Line comment at first column" is on.

I tried it. 

No, it does not add a space after the // comment start.

0
Comment actions Permalink

works fine for me - space after '//' is inserted when commenting code with line comment/pressing Enter on commented line. What did you do namely?

0
Comment actions Permalink

Well, I described exactly what I'm doing in my first post.  If there's anything I can clarify, please let me know.

I should have mentioned my version number: PhpStorm 2016.1.2.  Is that the version you're using?

space after '//' is inserted when commenting code with line comment/pressing Enter on commented line.

I'm seeing a space inserted when performing the Comment With Line Comment command on non-commented lines that have non-whitespace characters, but not:

  • When continuing a commented line (i.e. pressing enter in a commented line if there are character(s) after the cursor.)  This is my main concern and is the one I described in my first post.
  • When performing the Comment With Line Comment command when the cursor is on a line that is either empty or consists only of whitespace.
0
Comment actions Permalink

>When continuing a commented line (i.e. pressing enter in a commented line if there are character(s) after the cursor.)  This is my main concern and is the one I described in my first post.

 

works fine for me. Please record a screencast that shows up the issue

 

 

0
Comment actions Permalink

Here's an animated GIF of me pressing Enter.  I hope this clarifies the problem.

0
Comment actions Permalink

I see:) this only happens when pressing Enter within a word. Please vote for https://youtrack.jetbrains.com/issue/WI-27418.

if you have

// first second

Enter after 'first' or before 'second' will create properly formatted comment

0

Please sign in to leave a comment.