Home Download Buy Blog Forum Support

Multiline comment snippet (for JavaScript)

Multiline comment snippet (for JavaScript)

Postby rafaelrinaldi on Tue Feb 12, 2013 6:46 pm

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

Code: Select all
   /**
   * foo
   */


I already have the following snippet, which is working:

Code: Select all
<snippet>
   <content><![CDATA[/**
* $0
*/]]></content>
   <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
   <tabTrigger>/</tabTrigger>
   <!-- Optional: Set a scope to limit where the snippet will trigger -->
   <scope>source.js, source.actionscript.3</scope>
</snippet>


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:

Image

Image

Note that in the second one, which is responsible to add a new line to the comment has its source set to
Code: Select all
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?
rafaelrinaldi
 
Posts: 9
Joined: Tue Feb 12, 2013 6:36 pm

Re: Multiline comment snippet (for JavaScript)

Postby skuroda on Wed Feb 13, 2013 4:48 am

Have you tried out the DocBlockr plugin? It may do what you want already, and maybe some things you haven't thought of yet :D). 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.
skuroda
 
Posts: 685
Joined: Fri Oct 05, 2012 8:11 am

Re: Multiline comment snippet (for JavaScript)

Postby rafaelrinaldi on Wed Feb 13, 2013 5:12 am

Yeah, this seems to do the trick. Thank you @skuroda!
rafaelrinaldi
 
Posts: 9
Joined: Tue Feb 12, 2013 6:36 pm



Return to General Discussion

Who is online

Users browsing this forum: No registered users and 20 guests