Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Big comments with Sublime Text 2

Tags:

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!

like image 677
Randomblue Avatar asked Sep 24 '11 12:09

Randomblue


People also ask

How do you comment a block of code in Sublime Text?

The shortcut to comment out or uncomment the selected text or current line: Windows: Ctrl + / Mac: Command ⌘ + / Linux: Ctrl + Shift + /

What is the difference between Sublime Text 2 and 3?

Here's why – Sublime Text 3 brings some major benefits compared to version 2: Most plugins have caught up and are built on top of ST3 now. If you check in Package Control, there are more ST3 packages today than there are ST2 packages. Sublime Text 2 development has stopped while Sublime Text 3 is in active development.


2 Answers

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

like image 180
GNi33 Avatar answered Oct 08 '22 10:10

GNi33


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 // ////////////////// 
like image 43
nickf Avatar answered Oct 08 '22 10:10

nickf