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!
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
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 //
//////////////////
You could also try using the DocBlockr plugin
Use this handy sublime plugin https://packagecontrol.io/packages/Comment-Snippets
精彩评论