TextMate Bundle for jQuery
JonBob and I have been working on a TextMate bundle for jQuery over the past few weeks. If you’re not familiar with TextMate and you own a Mac, you should definitely check it out. It has saved me countless hours of repetitive keystrokes with its bundles, which contain commands, code snippets, templates, and macros that are triggered by pressing special key combinations or clicking menu items.
The jQuery bundle that we put together mostly consists of “tab triggers” for various functions, but it also includes context-sensitive help derived from the online documentation and some nice syntax highlighting. After selecting jQuery as your file type in TextMate, you could, for example, type ready and press the Tab key to produce this:
$(document).ready(function() {
// Stuff to do as soon as the DOM is ready;
});
It’ll then select the commented line (line 2 in this example) for you so you can start typing right away, replacing the comment with your code. Hit the Tab key once more and it drops you onto a new line below the closing brackets. If you want to learn more about a function that you’ve typed in, just click anywhere inside its name and press Control + H. You’ll get official documentation on the function.
Get the Bundle
So, how can you get this cool jQuery bundle and speed up your coding? First, you’ll need TextMate, of course. If you don’t have it yet, download the 30-day trial. Then you’ll need to either check out the bundles from the Subversion repository (advanced) or download and install the GetBundles bundle.



October 10th, 2006 at 7:27 pm
Hello!
I am using your jQuery bundle but one thing really annoys me: I can’t use the jQuery bundle when the pagetype is set to HTML.
The Javascript bundle can handle it. When I add to my document the Javacript tab trigger is fired by entering ‘fun’ and pressing TAB.
Your bundle however doesn’t seem to react so what do I have to edit so that I can use the jQuery commands even when the current language is set to ‘HTML’?
Thanks!
October 10th, 2006 at 7:31 pm
Ah sorry for the double response.. I think I got it:
Just edit the snippets and change the Scope Selectors from ’source.js.jquery’ to ’source.js’ and you can use your jQuery bundle even inline on a normal HTML document without the need to use the HTML bundle.
February 11th, 2007 at 11:55 am
First of all, thanks for a great bundle
You can also activate it in the HTML bundle:
{
name = 'source.js.jquery.embedded.html';
begin = '(?:^\s+)?(<)((?i:script))\b(?![^>]*/>)';
end = '(?<=</(script|SCRIPT))(>)(?:\s*\n)?';
patterns = (
{ include = "source.js.jquery"; }
);
},
February 11th, 2007 at 12:02 pm
Excellent, Michael! Thanks for that tip on activating it in the HTML bundle. I’ve been wanting to do that for a while.
Your comment has inspired me to update the bundle, too, so look for a newer version within the next couple weeks!
March 23rd, 2007 at 1:19 pm
Thanks a lot for this, Karl!
March 23rd, 2007 at 1:23 pm
Sure thing, Klaus. I’m a little embarrassed now, though, because I haven’t updated it yet. And it’s in serious need of some love. I’ll send you a revised bundle soon and update this entry/link.
July 5th, 2007 at 3:10 pm
Make sure you put the above code from Michael above the current javascript one in the HTML bundle, otherwise it won’t work.
August 11th, 2007 at 4:43 pm
It would be nice if you altered the bundle to use cross-platform friendly filenames (no colons, etc), so that those of us working with the E Texteditor in windows could use it as well.
September 1st, 2007 at 5:22 pm
I am having no luck with this. I downloaded the get bundle and there is nothing to really double click on it is a zip file uncompressed there are folders and I can double click on which puts them in Dan Stein’s Bundles but they don’t do anything from there. I select one like install but I get no error and no list
So not sure where to go from here. I can see the bundle on the textmate site but not sure what I would do with it from there.
Help!
September 2nd, 2007 at 9:19 am
I use e-TextEditor on Windows XP. It uses same bundles as TextMate. I downloaded GetBundles bundle. I just extracted it in “bundles” folder (nothing to double-click?). But when I click “Install Bundle” nothing happens but just an empty drop down list. I know there are lots of bundles on macromates svn but I cannot svn them as some file names are not compatible with the windows system. GetBundles bundle don’t work too.
So is there a zipped version of JQuery bundle, so we can extract zip into bundles directory?
Regards…
September 2nd, 2007 at 11:24 am
Jonathan and I have been distracted for quite some time by the book writing, but now that we’re finished with that, I’m hoping we can spend some time in the coming weeks updating the bundle. When the update is ready, I’ll post a new entry here. If I forget to include a link to a zip file, please gently remind me.
September 4th, 2007 at 11:19 pm
I’ll take a look at this bundle and see what can be done to make it compatible with the e Text Editor. I don’t know if the Bet Bundles command will work out of the box, and as other’s have noted there are Mac filenames which are illegal under Windows.
For now you can use the ebundles repository (http://ebundles.googlecode.com/svn/trunk/), which has bundles which are fully ported to e, and the tmbundles4win repository which is the raw TextMate (MacroMates) repository with Windows-legal filenames but absolutely no porting done (http://tmbundles4win.googlecode.com/svn/trunk/). This latter repo may have many commands that will not currently work OOTB with e, but at least all the filenames are legal (and you can get snippets and syntax going right away). The jQuery bundle is here: http://tmbundles4win.googlecode.com/svn/trunk/Bundles/jQuery.tmbundle/
Most things that don’t work under e are bundle commands that use Mac-only features (AppleScript being one of the most notable) and Macros (yet to be implemented).
November 7th, 2007 at 4:27 am
Hi there,
I am highly interested in that bundle. But I am experiencing the same problems on Win XP like my friends before me.
Is there a update and a ZIP File on the way?
Greez
Kuddl
February 17th, 2008 at 11:38 pm
Hello! I am trying to scope this bundle to HTML, and I’m having difficulty doing so. I put in Michael’s code above the JavaScript scope code in the bundle but I get an error on line 1:2. What am I doing wrong?
Thanks very much for your hard work on the bundle. It looks great!
Regards,
Matt
March 6th, 2008 at 2:55 pm
Hello. Great bundle, but I also would like it to work on embedded JS code in my HTML, PHP, and ASP documents.
I saw the above post, saying to put this in:
{
name = 'source.js.jquery.embedded.html';
begin = '(?:^\s+)?(]*/>)';
end = '(?<=)(?:\s*\n)?';
patterns = (
{ include = "source.js.jquery"; }
);
},
But put it where, exactly? In this bundle language module, or in the html language module?
And WHERE in the language module code block?
Thanks.
March 6th, 2008 at 9:21 pm
Hi Steve,
Try this. In the Edit Bundle list, expand the HTML bundle and look for the HTML with the gray “L” next to it. Click on that and then click in the text area to the right. Select all (Command-a) and then copy (Command-c). Paste it into a new text file and save it in case something doesn’t work right. Paste it into another text file and then do a Find for this line:
Right before that line, but after the previous line, paste this:
Close the bundle editor. You might then have to go to Bundles > Bundle Editor > Reload Bundles.
That worked for me. Hope it works for you as well!
March 20th, 2008 at 6:31 pm
Very strange– it looks like it should work, but for some reason I can’t get it to active in the HTML bundle, either. I’m pointing right to it, like the example you provided. I even went in and modified the existing javascript include and added the { include = ’source.js.jquery’; }, and it still won’t activate. Ah well.
Thanks for the bundle though! It’s very handy to have so I don’t have to go to docs.jquery.com for simple things any more!
April 12th, 2008 at 7:54 pm
I think the scope of the bundle should be source.js by default. I’ve tried the solutions here, it does not seem to work for me (except changing the scope like the second comment).
This is a great bundle, thanks to everyone involved.