+3

phpdoc new lines

U N. 13 years ago updated by Victor Cinaglia 12 years ago 2
There is already some support for inline documentation (syntax higlihighting, at least for phpdoc). E.g. in:

/**
 * @var bool
 */
@var is highlighted. If the comment starts as "/*" instead of "/**", the highlighting is gone, which is to be expected. Wouldn't it be good to extend this distinct behavior further ahead, by adding a little more, namely: when pressing <enter> within the "/**" comment block, the new line should start with the usual space padding, followed by the " * ". The thing is that at least for phpdoc, lines within the "/**" comment block, not starting with an asterisk, are ignored by documentation generator. So one has to manually add asterisks at the beginning of each line. Auto adding it would be a great help.

I was just about to post this with the title "Comment block auto asterisk on new line". I think this would get more up-votes if it showed up in searches better. ANYWAY.


THIS! I write a fair amount of JavaDoc format comments in my larger projects, and sometimes I just need to write a comment that is a few lines in the code. I would love this feature or at least a way to add it with snippets. <tabTrigger> doesn't quite cut it here.


Note: As a temporary solution, I just write them with no * at the beginning and then do a multi-line select (Cmd+Alt+Click-Drag) at the beginning of the lines and type " * ".

Hey guys, this might not be the best solution out there, but it's better than nothing.

<code>

{

    "keys": ["enter"],

    "command": "insert_snippet",

    "args"   :   {

        "contents": "\n* "

    },

    "context": [

        { "key": "selector", "operator": "equal", "operand": "source.php comment.block" }

    ]

}

</code>


Just add the above to your user's Key Bindings file. Hope it helps.