Skip to content

Instantly share code, notes, and snippets.

@agibsonsw
agibsonsw / switch.sublime-snippet
Created February 4, 2012 15:22
Sublime snippet - JS switch statement
<snippet>
<content><![CDATA[switch (${1:expression}) {
case ${2:test1}:
${3:statement1};
break;
${4:case ${5:test2}:
${6:statement2};
break;}
default:
${7:// to do}
@agibsonsw
agibsonsw / fontFamily.sublime-snippet
Created February 13, 2012 13:51
CSS fontFamily (abbr)
<snippet>
<content><![CDATA[font-family: ${1/\\|(Ar)|(AB)|(BA)|(BO)|(Ch)|(CN)|(Co)|(CS)|(Gar)|(Gad)|(Gen)|(Geo)|(He)|(Im)|(LC)|(LG)|(LS)|(Mo)|(Sa)|(Se)|(NY)|(Pa)|(PL)|(Ta)|(TN)|(Ti)|(Tr)|(Sy)|(Ve)|(se)|(sa)|(fa)|(mo)|(\,)|_([a-zA-Z0-9\-\ ]+)_/?1:Arial:?2:'Arial Black':?3:'Book Antiqua':?4:'Bookman Old Style':?5:Charcoal:?6:'Courier New':?7:Courier:?8:'Comic Sans MS':?9:Garamond:?10:Gadget:?11:Geneva:?12:Georgia:?13:Helvetica:?14:Impact:?15:'Lucida Console':?16:'Lucida Grande':?17:'Lucida Sans Unicode':?18:Monaco:?19:'MS Sans Serif':?20:'MS Serif':?21:'New York':?22:Palatino:?23:'Palatino Linotype':?24:Tahoma:?25:'Times New Roman':?26:Times:?27:'Trebuchet MS':?28:Symbol:?29:Verdana:?30:serif:?31:sans-serif:?32:fantasy:?33:monospace:?34:, :?35:\x27$35\x27/g};${3:/* ${1:fonts } */}
]]></content>
<tabTrigger>fontFamily</tabTrigger>
<scope>source.css meta.property-list.css</scope>
<description>Use TI for Times etc</description>
</snippet>
@agibsonsw
agibsonsw / borderColor.sublime-snippet
Created February 13, 2012 16:49
CSS borderColor
<snippet>
<content><![CDATA[border-color: ${1/\\|colour|(az)|(aq)|(be)|(bla)|(br)|(bl)|(ch)|(cy)|(fu)|(go)|(gre)|(gr)|(li)|(mag)|(ma)|(na)|(or)|(ol)|(pl)|(pu)|(pi)|(si)|(te)|(tr)|(vi)|(wh)|(ye)|(re|r)/?1:azure:?2:aqua:?3:beige:?4:black:?5:brown:?6:blue:?7:chocolate:?8:cyan:?9:fuchsia:?10:gold:?11:green:?12:gray:?13:lime:?14:magenta:?15:maroon:?16:navy:?17:orange:?18:olive:?19:plum:?20:purple:?21:pink:?22:silver:?23:teal:?24:transparent:?25:violet:?26:white:?27:yellow:?28:red/g};$0${3:/* ${1:colour } */}
]]></content>
<tabTrigger>borderColor (test)</tabTrigger>
<scope>source.css meta.property-list.css</scope>
<description>ma for maroon, use spaces</description>
</snippet>
@agibsonsw
agibsonsw / propx.sublime-snippet
Created February 14, 2012 21:54
CSS propx snippet
<snippet>
<content><![CDATA[$0${TM_CURRENT_LINE/\\|(?:\b| )((BO)|(CLI)|(CO)|(CU)|(CL)|(DI)|(FF)|(FL)|(FO)|(HE)|(LE)|(MA)|(PA)|(PO)|(RI)|(TO)|(WE)) |( {2,}|\t)/?2:;\nbottom\: :?3:;\nclip\: :?4:;\ncolor\: :?5:;\ncursor\: :?6:;\nclear\: :?7:;\ndisplay\: :?8:;\nfont-family\: :?9:;\nfloat\: :?10:;\nfont\: :?11:;\nheight\: :?12:;\nleft\: :?13:;\nmargin\: :?14:;\npadding\: :?15:;\nposition\: :?16:;\nright\: :?17:;\ntop\: :?18:;\nwidth\: /gi};
]]></content>
<tabTrigger>propx</tabTrigger>
<scope>source.css meta.property-list.css</scope>
<description>po to, etc</description>
</snippet>
@agibsonsw
agibsonsw / propx.sublime-snippet
Created February 18, 2012 17:00
CSS propx snippet (final - not quite)
<snippet>
<content><![CDATA[/* ${1} : ${1/($)|.*(?:\b| )((b)|(c)|(d)|(e)|(f)|(h)|(l)|(m)|(o)|(p)|(q)|(r)|(t)|(v)|(w)|(z)).?$|.*/?1:Type to for top etc., followed by a space:?3:BAckground-Attach etc BOTtom BOrder-Collapse-Spacing BC BS BW BorderBottom\(Color\/Style\/Width\) etc:?4:CLear CLIp COlor CONtent CUrsor Counter-Inc-Reset Caption-Side:?5:DIsplay DIRection:?6:Empty-Cells:?7:FOnt F-Family-SI\/ST\/W\/V FLoat:?8:HEight:?9:LEft LEtter-Spacing Line-Height List-Style I\/P\/T:?10:MArgin T\/R\/B\/L MAx\/MIn-Height\/Width:?11:OUtline-Color-Style-Width OVerflow:?12:PAdding T\/R\/B\/L POsition-Abs\/Rel\/Fixed\/Static:?13:QUotes:?14:RIght:?15:TOp TExt-Align\/D\/I\/T:?16:Vertical-Align VIsibility:?17:WHite-space WIdth WOrd-spacing:?18:Z-index/i} */$0${1/\\|(?:\b| )((ba((a)|(c)|(i)|(p)|(r))?)|(bot)|(bo((c)|(s))?)|(((bb)|(bl)|(br)|(bt)|b)((c)|(s)|(w))?)|(cli)|(con)|(co)|(cu)|(cl)|(c((i)|(r)))|(cs)|(dir)|(di)|(ec)|((ff)|(fsi)|(fst)|(fv)|(fw)|fo)|(fl)|(he)|(les)|(le)|(lh)|(ls((i)|(p)|(t))?)|(((ma)|(mi))((h)|(w)))|(((ma
@agibsonsw
agibsonsw / propx.sublime-snippet
Created February 19, 2012 17:00
css propx snippet (final)
<snippet>
<content><![CDATA[/* ${1}
${1/($)|.*(?:^| )((b)|(c)|(d)|(e)|(f)|(h)|(l)|(m)|(o)|(p)|(q)|(r)|(t)|(v)|(w)|(z)).?$|.*/?1:Type to for top etc, followed by a space:?3:BAckground-Attach etc BOTtom BOrder-Collapse-Spacing-Bottom\(Color\/Style\/Width\) etc BC BS BW:?4:CLear CLIp COlor CONtent CUrsor Counter-Inc-Reset Caption-Side:?5:DIsplay DIRection:?6:Empty-Cells:?7:FOnt F-Family-SI\/ST\/W\/V FLoat:?8:HEight:?9:LEft LEtter-Spacing Line-Height List-Style I\/P\/T:?10:MArgin T\/R\/B\/L MAx\/MIn-Height\/Width:?11:OUtline-Color-Style-Width OVerflow:?12:PAdding T\/R\/B\/L POsition-Abs\/Rel\/Fixed\/Static:?13:QUotes:?14:RIght:?15:TOp TExt-Align\/D\/I\/T:?16:Vertical-Align VIsibility:?17:WHite-space WIdth WOrd-spacing:?18:Z-Index/i}${1/($)|.*(?:\b| )((baa)|(bap)|(bar)|((b[trbl]?s)|(ous))|(b[trbl]?w|ouw)|(boc)|(cl)|(cu)|(cs)|(dir)|(di)|(ec)|(fl)|(fsi)|(fst)|(fv)|(fw)|((bot|to|le|ri|he|wi|mat|mar|mab|mal|ma)|(mah|maw)|mih|miw|pa[trbl]?|tei)|((lh)|ls)|(lsi)|(lsp)|(lst)|(ov)|(tea)|(ted)|(tet)|(va)|(vi)|(wh)|(wo)|
@agibsonsw
agibsonsw / propx.sublime-snippet
Created February 19, 2012 20:51
css propx snippet important
<snippet>
<content><![CDATA[/* ${1}
${1/($)|.*(?:^| )((b)|(c)|(d)|(e)|(f)|(h)|(l)|(m)|(o)|(p)|(q)|(r)|(t)|(v)|(w)|(z)).?$|.*/?1:Type to for top etc, followed by a space:?3:BAckground-Attach etc BOTtom BOrder-Collapse-Spacing-Bottom\(Color\/Style\/Width\) etc BC BS BW:?4:CLear CLIp COlor CONtent CUrsor Counter-Inc-Reset Caption-Side:?5:DIsplay DIRection:?6:Empty-Cells:?7:FOnt F-Family-SI\/ST\/W\/V FLoat:?8:HEight:?9:LEft LEtter-Spacing Line-Height List-Style I\/P\/T:?10:MArgin T\/R\/B\/L MAx\/MIn-Height\/Width:?11:OUtline-Color-Style-Width OVerflow:?12:PAdding T\/R\/B\/L POsition-Abs\/Rel\/Fixed\/Static:?13:QUotes:?14:RIght:?15:TOp TExt-Align\/D\/I\/T:?16:Vertical-Align VIsibility:?17:WHite-space WIdth WOrd-spacing:?18:Z-Index/i}${1/($)|.*(?:\b| )((baa)|(bap)|(bar)|((b[trbl]?s)|(ous))|(b[trbl]?w|ouw)|(boc)|(cl)|(cu)|(cs)|(dir)|(di)|(ec)|(fl)|(fsi)|(fst)|(fv)|(fw)|((bot|to|le|ri|he|wi|mat|mar|mab|mal|ma)|(mah|maw)|mih|miw|pa[trbl]?|tei)|((lh)|ls)|(lsi)|(lsp)|(lst)|(ov)|(po)|(tea)|(ted)|(tet)|(va)|(vi)|(wh)|
@agibsonsw
agibsonsw / LastEditLine.py
Created March 4, 2012 19:21
ST Python to move between last edits
import sublime, sublime_plugin
POSITIONS = {}
class LastEditLineCommand(sublime_plugin.TextCommand):
posn = 0
def run(self, edit):
vid = self.view.id()
if not POSITIONS.has_key(vid): return
if len(POSITIONS[vid]) <= self.posn + 1:
@agibsonsw
agibsonsw / LastEditLine.py
Created March 7, 2012 13:32
ST Python to move between last edits (perfect)
import sublime, sublime_plugin
POSNS = {} # Based on each view's id, store edited positions.
# The first element stores the most recently edited line
# number, so that the same line is not saved repeatedly.
class LastEditLineCommand(sublime_plugin.TextCommand):
posn = -1 # always add 2 to this, which indexes the first
# edited position (for the current view)
def run(self, edit):
@agibsonsw
agibsonsw / OrderedFiles.py
Created March 7, 2012 17:04
ST navigate sorted files
import sublime, sublime_plugin, os, datetime
from operator import itemgetter
file_views = []
class OrderedFilesCommand(sublime_plugin.TextCommand):
def run(self, edit, index):
global file_views
file_views = []
for vw in self.view.window().views():