Sublime Forum

Multiline comment snippet (for JavaScript)

#1

Hey guys, I’m trying to make a snippet to make it easier to create multiline comments in JavaScript following the standard:

/** * foo */

I already have the following snippet, which is working:

[code]
<![CDATA[/**

  • $0
    */]]> / source.js, source.actionscript.3
    [/code]

The thing is that I want to know if I’m able to trigger the new line entries inside this comment block and replace it with *****. This way I’m able to write the multiline comment without worrying about the size of it.

In TextMate I have this working like a charm. I have two snippets:

https://dl.dropbox.com/u/3420025/Images/Misc/sublime-text-forum/multiline-comment-tm-1.png

https://dl.dropbox.com/u/3420025/Images/Misc/sublime-text-forum/multiline-comment-tm-2.png

Note that in the second one, which is responsible to add a new line to the comment has its source set to comment.block.documentation. This is because TextMate let me set the snippet source as the comment block.

Is there any way to accomplish this with Sublime Text?

0 Likes

#2

Have you tried out the DocBlockr plugin? It may do what you want already, and maybe some things you haven’t thought of yet :smiley:). If you don’t want all of the functionality, it may be helpful in doing what you want (I would take a look at the keymap file using “enter”).

Hope that helps.

0 Likes

#3

Yeah, this seems to do the trick. Thank you @skuroda!

0 Likes

#4

Plugin - Comments Aware Enter for Sublime Text 2

0 Likes