Sublime Text 2 评论/文档块

发布于 2024-12-05 04:48:12 字数 328 浏览 2 评论 0原文

最近,我决定尝试使用 Sublime Text 2 作为 TextMate 的替代品(确实如此)。我非常喜欢它,但唯一让我烦恼的问题是,按“Enter”键后它不会继续 PHP 注释/文档块。

它只是添加新的空行而不是以“*”开头的行,如下所示 http://cl.ly/AFcP/o

有解决方案吗?我尝试为其进行按键绑定,但这对我来说太复杂了,特别是因为我对编辑器不太有经验。

提前致谢。

Recently, I decided to try out Sublime Text 2 as a TextMate alternative (which it is). I'm absolutely loving it but the only issue that bugs me is that it doesn't continue the PHP Comment/Doc Block upon pressing "Enter".

It just adds new blank lines instead of lines starting with "* " as seen here http://cl.ly/AFcP/o

Is there a solution to this? I tried doing a key binding for it but it was just too complicated for me, especially because I'm not too experienced with the editor.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

明媚殇 2024-12-12 04:48:12

现在有了更好的解决方案:

https://github.com/spadgos/sublime-jsdocs

它被称为DocBlockr,并且它有 PHPDoc 支持。它根据函数参数自动添加文档块。好的...

And now an even better solution has become available:

https://github.com/spadgos/sublime-jsdocs

It is called DocBlockr, and it has PHPDoc support. It automatically adds the doc block based on the function parameters. Nice...

情栀口红 2024-12-12 04:48:12

刚刚遇到了同样的问题,写了一个小片段。由于它是一个键绑定,因此必须存储在 .sublime-keymap 文件中。如果您使用的是 Mac,只需转到 Sublime Text 2 >首选项>键绑定 - 用户或其他操作系统上的类似键。

这是我的代码:

[
{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n * "}, "context": [
    {"key": "selection_empty", "operator": "equal", "operand": true},
    {"key": "preceding_text", "operator": "regex_contains", "operand": "\\/\\*\\*$", "match_all": true}
]},
{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n* "}, "context": [
    //{"key": "selection_empty", "operator": "equal", "operand": true},
    {"key": "preceding_text", "operator": "regex_contains", "operand": "^[\t ]*\\*[^\\/]", "match_all": true}
]}
]

Just had the same problem and wrote a little snippet. Since it is a keybinding it has to be stored in a .sublime-keymap File. If you're on a Mac just goto Sublime Text 2 > Preferences > Key Bindings - User or similar on some other OS.

Here is my Code:

[
{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n * "}, "context": [
    {"key": "selection_empty", "operator": "equal", "operand": true},
    {"key": "preceding_text", "operator": "regex_contains", "operand": "\\/\\*\\*$", "match_all": true}
]},
{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n* "}, "context": [
    //{"key": "selection_empty", "operator": "equal", "operand": true},
    {"key": "preceding_text", "operator": "regex_contains", "operand": "^[\t ]*\\*[^\\/]", "match_all": true}
]}
]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文