在textmate中,如何像在eclipse中一样进行javadoc风格的注释?
在 Eclipse 中,当我想要记录一个函数(在 java 或 javascript 源代码中)时,我只需输入 /**,然后按 Enter 键,然后我会得到这样的注释
/**
*
* Fluctuates all variables to more compatibly foo all the bars
*
* @PARAM {int} foo
*/
function flucvar (foo) {
}
当在注释中按 Enter 键时,Eclipse 会自动在注释处添加额外的 *每行的开头。
现在我刚刚进入我的文本伙伴状态,发现自己缺少这一点功能。 是否有等效的捆绑包或命令或其他东西可以让我在 textmate 中生成类似的评论?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要创建两个片段(我将它们放在源包中)。
首先创建一个用于插入 JavaDoc 注释的代码片段。 该代码段包含以下内容:
我将代码段激活设置为 Tab 触发器,使用
/**
作为激活字符串。 每次我写/**
并按 Tab 时,我都会得到一个 JavaDoc 注释块。 如果您愿意,也可以使用键盘快捷键。第二个片段用于继续现有的 JavaDoc 注释。 代码片段内容为:
请注意,
* $0
行之前有一个空行。 将“激活”设置为等效键,并将触发键设置为返回键。 将范围选择器字符串设置为comment.documentation
。现在,如果您的语言包支持
comment.documentation
范围(就像所有包含的包一样),您应该有 JavaDoc 注释的工作快捷方式。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:
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:
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 tocomment.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.我查看了 TextMate 的 Java 包,没有看到任何关于插入 JavaDoc 注释的内容。 然而,将这样的功能添加到您的 Java 包中应该不难。 它可能是一个片段,您可以在 TextMate 手册的第 7 章中阅读(从
帮助 -> TextMate 帮助
访问)。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
).谢谢你的回答。 我刚刚在 Macromates 网站
http://blog.macromates.com/2006/ 上找到了这篇文章customization-screencast/
这似乎有一个视频/邮件列表帖子,准确地解释了如何做到这一点。
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.