Home Download Buy Blog Forum Support

Improved Comments and Comment Banners

Improved Comments and Comment Banners

Postby SparrwHawk on Mon Mar 28, 2011 11:02 am

I'm surprised the comments function in Sublime Text 2 isn't more intuitive. 'Toggle Comments' works fine for toggling existing comments, but it works poorly for inserting new comments. For example if a comment is not present I expect the Toggle Comments keyboard shortcut to place my cursor in the middle of the comment tags e.g. /* <cursor automatically placed here> */

I'd also really like to see a comment banner feature like TextMate's, where I can easily mark key sections with a big comment banner like this...

/*------------------------------------------- HEADINGs -------------------------------------------*/
SparrwHawk
 
Posts: 2
Joined: Mon Mar 28, 2011 10:48 am

Re: Improved Comments and Comment Banners

Postby jchristopher on Tue Aug 02, 2011 10:50 am

I'd also love to see something like TextMate's comment banner functionality, hitting CTRL+SHIFT+B gives you a nice way to make a more obvious, 3 line comment along the lines of:

Code: Select all
// ---------------------
// --- GLOBAL STYLES ---
// ---------------------


where the top and bottom lines are auto-sized based on the string in the middle and the comment type is scope-aware.
jchristopher
 
Posts: 2
Joined: Tue Aug 02, 2011 10:46 am

Re: Improved Comments and Comment Banners

Postby guillermooo on Tue Aug 02, 2011 11:03 am

Tweak as needed:

Code: Select all
<snippet>
    <content><![CDATA[==${1/./=/g}
= ${1:Your Comment Goes here}
==${1/./=/g}]]></content>
    <tabTrigger>comm</tabTrigger>
    <scope>text.plain</scope>
</snippet>
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am

Re: Improved Comments and Comment Banners

Postby guillermooo on Tue Aug 02, 2011 11:05 am

Note that Sublime Text doesn't seem to be very resilient to malformed snippets at the moment. It just crashed on me now because I made a typo while testing the snippet above.
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am

Re: Improved Comments and Comment Banners

Postby jbrooksuk on Tue Aug 02, 2011 9:52 pm

I've noticed that comments arent very good in Sublime as well.

Mainly when I try to comment code in source.HTML I get PHP style comments instead of HTML ones, which is very annoying. I assume it's based on the file type, not the current region source?
jbrooksuk
 
Posts: 782
Joined: Sun Apr 11, 2010 10:37 am
Location: England

Re: Improved Comments and Comment Banners

Postby jchristopher on Wed Aug 03, 2011 1:51 pm

Awesome, thanks!
jchristopher
 
Posts: 2
Joined: Tue Aug 02, 2011 10:46 am

Re: Improved Comments and Comment Banners

Postby guillermooo on Wed Aug 03, 2011 2:15 pm

jbrooksuk, .tmPreferences files, where comment-toggling is defined, do let you specify scope selectors. That makes me think they are not (only) bound to file types. But I haven't really tested... In the past there were many glitches with comment toggling, but at least for Python the situation seems to have improved.
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 7 guests