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.
请先登录再写评论。
Did you try Settings|Code Style|PHP|Other|Comment Code, "Add a space at comment start"?
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.
works fine for me - space after '//' is inserted when commenting code with line comment/pressing Enter on commented line. What did you do namely?
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.
works fine for me. Please record a screencast that shows up the issue
Here's an animated GIF of me pressing Enter. I hope this clarifies the problem.
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
If you use tslint or eslint can customize the rules
Here I implemented the tslint rule
https://github.com/yanxiaojun617/ionic2_tabs/tree/master/custom-tslint-rules
https://www.jianshu.com/p/00d053238314