Skip to content

Instantly share code, notes, and snippets.

@s-taylor
Last active August 29, 2015 13:57
Show Gist options
  • Save s-taylor/9925077 to your computer and use it in GitHub Desktop.
Save s-taylor/9925077 to your computer and use it in GitHub Desktop.
Sublime Text 2 Snippets

#Snippet Instructions...


##Create a new Snippet

  1. Tools > New Snippet...

  2. Put your code in here (don't delete the cdata tags)...

  3. Uncomment the tabTrigger tags and input the text shortcut you want to use for this tab e.g. switch

  4. Uncomment the scope tags if you want to restrict this code to only operate on certain file extensions i.e. if you want a ruby 'if' snippet and a javascript 'if' snippet For Ruby use... source.rb For Javascript use... source.rb

  5. Save your file This will automatically default to the correct folder Make sure the file extension ".sublime-snippet"


##Using your Snippet type your tabTrigger keyword and press TAB


##If you want to override a default snippet...

  1. First you need to remove the default snippet Navigate to "/Users/USERNAME/Library/Application Support/Sublime Text 2/Packages/LanguageName"

  2. Open the relevant folder /JavaScript OR /Ruby

  3. Find the relevant snippet and rename it (I don't recommend deleting it!) I just put .UNUSED on the end so it was no longer picked up


##Issues

If you find your snippet deletes itself when you press TAB it is possible you need to escape a character in your section. If you have a "$" sign, try change this to "$"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment