My most useful Sublime Text 2 SnippetsPosted on: May 18, 2012

I love Sublime Text, and if you haven't used it before, you should definitely check it out!

One of the best parts for me is that you can create your own snippets... check out the documentation to find out how to do that.

Below is a list of my own snippets (unless otherwise stated) that I just can't do without (I'll hopefully keep this list up to date and add more as I find/create them):


Javascript

<snippet>
	<content><![CDATA[jQuery(function(\$) {
	$0
});]]></content>
	<tabTrigger>jd</tabTrigger>
	<scope>source.js</scope>
</snippet>
<snippet>
	<content><![CDATA[jQuery(document).load(function(\$) {
	$0
});]]></content>
	<tabTrigger>jl</tabTrigger>
	<scope>source.js</scope>
</snippet>
<snippet>
	<content><![CDATA[/*===== $0 =====*/]]></content>
	<tabTrigger>/*=</tabTrigger>
</snippet>
<snippet>
	<content><![CDATA[if(window.console&amp;&amp;console.log)console.log($1);$0]]></content>
	<tabTrigger>cl</tabTrigger>
	<scope>source.js</scope>
</snippet>
<snippet>
	<content><![CDATA[function${1: name}($2) {
	$0
}${3:;}]]></content>
	<tabTrigger>fx</tabTrigger>
	<scope>source.js</scope>
</snippet>
<snippet>
	<content><![CDATA[).click(function(${1:e}) {
	$0${2:
	$1.preventDefault();${3:
	return false;}}
});]]></content>
	<tabTrigger>).click</tabTrigger>
	<scope>source.js</scope>
</snippet>
<snippet>
	<content><![CDATA[).change(function(${1:e}) {
	$0${2:
	$1.preventDefault();${3:
	return false;}}
});]]></content>
	<tabTrigger>).change</tabTrigger>
	<scope>source.js</scope>
</snippet>
<snippet>
	<content><![CDATA[.each(${1:${2:arrayName}, }function(${3:i, val}) {
	$0
});]]></content>
	<tabTrigger>.each</tabTrigger>
	<scope>source.js</scope>
</snippet>
<snippet>
	<content><![CDATA[).submit(function(${1:e}) {
	$0${2:
	$1.preventDefault();${3:
	return false;}}
});]]></content>
	<tabTrigger>).submit</tabTrigger>
	<scope>source.js</scope>
</snippet>

PHP

<snippet>
	<content><![CDATA[echo "<pre>";var_dump($0);die("</pre>");]]></content>
	<tabTrigger>die</tabTrigger>
	<scope>source.php</scope>
</snippet>
<snippet>
	<content><![CDATA[<?php echo "<pre>";var_dump($0);die("</pre>"); ?>]]></content>
	<tabTrigger>pdie</tabTrigger>
</snippet>