henry sztul

henry sztul

Physicist. Entrepreneur. Dad.
more about me @ henry.sztul.com


Javascript multi-line comments shortcut in Textmate

I am a huge fan of Textmate. I use it ALL the time for Ruby, Rails, HTML, CSS, and of course Javascript.

Commenting in most of those languages is really easy:

Ruby: # comment here

HTML: <!— comment here —>

Javascript: // comment here

What I have really wanted for some time is a keyboard shortcut to turn a line or two of text into a multiline Javascript comment.

Here’s what I ended up doing (image below shows it all):

1) In Textmate, get yourself into the ‘Bundle Editor’

2) Create a ‘new command’ (I called mine “Multiline Comment”

3) In the ‘Commands’ text area enter: echo “/* $TM_SELECTED_TEXT */”

4) Choose ‘Selected Text’ as the ‘Input’ and ‘Replace Selected Text’ as the ‘Output’

5) Choose a keyboard shortcut for the command under ‘Activation > Key Equivalent’ (I chose <shift>+<command>+c)

Voila!  Now you can type your comment, highlight it, and hit <shift>+<command>+c to get your multi-line commented area.

  1. henrysztul posted this
blog comments powered by Disqus
Top