Sublime Text 2 的大评论

发布于 2024-12-06 02:14:17 字数 212 浏览 0 评论 0原文

我想在 Sublime Text 2 中做出这样的评论:

/********************
* This is a comment *
********************/

是否有一种简单的方法可以自动进行这些评论?

另外,我在哪里可以找到有关此类内容的良好文档。我喜欢 Sublime,但我觉得它的文档很少!

I would like to make comments like this in Sublime Text 2:

/********************
* This is a comment *
********************/

Is there an easy way to make those automatically?

Also, where can I find good documentation about such stuff. I love Sublime, but I feel it's poorly documented!

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

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

发布评论

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

评论(4

玩心态 2024-12-13 02:14:17

您可以创建一个片段来执行此操作。

转到工具 -> New Snippet 并打开一个新文件。将其粘贴到其中:

<snippet>
<content>
<![CDATA[

/********************
* $0 *
********************/

]]>

</content>
<tabTrigger>bigcom</tabTrigger>
</snippet>

将其保存在您的 Packages\User 文件夹中(保存时应自动设置)。
现在,您只需输入 bigcom(如 - 元素中所定义)并点击 tab。注释将出现,并且光标将设置在代码段中设置 $0 的位置。

另外,您可以在 块内添加一个 scope - 元素,因此此代码片段仅在特定语法范围内工作,例如:

<scope>source.python</scope> 

Unfurtonately, I不知道当您跳到新行时如何在您正在写入的行的两侧自动添加 * 字符,所以我不知道这是否符合您的需求。您必须手动添加这些。我仍然希望这能在某种程度上有所帮助。

编辑:
在 stackoverflow 上的另一个问题中找到了一些相关内容。看看这个答案。执行此操作时,至少会添加新行开头的 * 字符。我会看看是否可以让它在行尾添加字符。


当谈到文档时,我同意,实际上并没有太多。当然有官方文档: Sublime Doc 当然论坛: Sublime Forum (从某种程度上来说,这是一个很好的资源,但不是喜欢填写得很差的医生)。另一方面,我总是建议阅读 net.tutsplus,这是一个很好的起点。

在浏览全局设置按键绑定文件时,我几乎偶然发现了标准安装中最有趣的部分,您可以通过打开它们首选项 - 菜单

You could create a snippet for doing this.

Go to Tools -> New Snippet and a new file is opened. Paste this in it:

<snippet>
<content>
<![CDATA[

/********************
* $0 *
********************/

]]>

</content>
<tabTrigger>bigcom</tabTrigger>
</snippet>

Save this in your Packages\User-Folder (which should be set automatically when saving).
Now you can just type bigcom (as defined in the <tabTrigger> - element) and hit tab. The comment will appear and the cursor is set at the position, where $0 is set in the snippet.

Additionaly, you could add a scope - element inside the <snippet>-block, so this snippet will only work in a specific syntax scope, for example:

<scope>source.python</scope> 

Unfurtonately, I don't know how you could add the *-character on both sides of the line you are writing in automatically, when you jump into a new line, so I don't know if this fits your needs. You would have to add those manually. Still I hope this helps in some way.

Edit:
Found something for this in another question on stackoverflow. Have a look at this answer. When doing this, at least the * character on the beginning of the new line is added. I'll have a look if I can get it to add the character at the end of the line too.


When it comes to the documentation, I agree, there's not really a lot out there. Of course there is the official documentation: Sublime Doc and of course the forum: Sublime Forum (which is a good resource to some point, not like the poorly filled Doc). On the other hand I always recommend reading the post on net.tutsplus, which is a nice starting point.

I pretty much stumbled over the most interesting parts that come with the standard installation while browsing trough the Global Settings and Key Bindings-Files, which you can open over the Preferences - Menu

愛放△進行李 2024-12-13 02:14:17

警告,自插。

DocBlockr 插件可以自动“装饰”一个为你评论。目前它仅适用于内联注释,但它可以完成工作。快捷键是 Ctrl+Enter

// foo bar baz

成为

/////////////////
// foo bar baz //
/////////////////

并且它也适用于连续注释:

// foo
// bar baz quux

成为

//////////////////
// foo          //
// bar baz quux //
//////////////////

Warning, self plug.

The DocBlockr plugin can automatically 'decorate' a comment for you. Right now it only works on inline comments, but it gets the job done. The shortcut key is Ctrl+Enter

// foo bar baz

Becomes

/////////////////
// foo bar baz //
/////////////////

And it works on consecutive comments too:

// foo
// bar baz quux

Becomes

//////////////////
// foo          //
// bar baz quux //
//////////////////
瞎闹 2024-12-13 02:14:17

您也可以尝试使用 DocBlockr 插件

You could also try using the DocBlockr plugin

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文