views:

823

answers:

3

In eclipse, when I want to document a function (in java or javascript source) I can just type /**, then hit enter, and I get a comment like this

 /**
 *
 * Fluctuates all variables to more compatibly foo all the bars
 *
 * @PARAM {int} foo 
 */  

function flucvar (foo) {

}

When hitting enter inside the comment, eclipse automatically adds extra * at the beginning of each line.

Now I'm just getting into my textmate groove, and finding myself missing this little bit of functionality. Is there an equivilent bundle or command or something that would allow me to produce similar comments in textmate?

+1  A: 

I took a look at TextMate's Java bundle, and I didn't see anything about inserting JavaDoc comments. However, it shouldn't be that hard to add such a feature to your Java bundle. It would likely be a Snippet, which you can read about in Chapter 7 of the TextMate manual (accessed from Help -> TextMate Help).

mipadi
A: 

thanks for that answer. I just found this post on the macromates site

http://blog.macromates.com/2006/customization-screencast/

this appears to have a video/mailing list post that explains precisely how to do this.

Breton
+4  A: 

You need to create two snippets (I have them in the Source bundle).

First create a snippet for inserting JavaDoc comments. The snippet contains the following:

/**
* $0
*/

I have the snippet Activation set to Tab Trigger, using /** as the activation string. Every time I write /** and press Tab, I get a JavaDoc comment block. You can also use a keyboard shortcut if you like.

The second snippet is for continuing existing JavaDoc comments. The snippet contents are:

* $0

Note that there is an empty line before the * $0 line. Set Activation to Key Equivalent and the trigger key to return key. Set the Scope Selector string to comment.documentation.

Now if your language bundle supports the comment.documentation scope (like all of the included bundles seem to do), you should have working shortcuts for JavaDoc comments.

Niko Nyman
Hooray! thank you!
Breton
To make this work for javascript, I had to set the Scope Selector to "comment.block.documentation".
morgancodes