Skip to content

Instantly share code, notes, and snippets.

@ZYinMD
Last active May 11, 2018 18:14
Show Gist options
  • Save ZYinMD/d754ac8256a24183b76496e50fc78e62 to your computer and use it in GitHub Desktop.
Save ZYinMD/d754ac8256a24183b76496e50fc78e62 to your computer and use it in GitHub Desktop.
JavaScript switch statement snippet for Sublime Text 3
<!-- Documentation: http://docs.sublimetext.info/en/latest/extensibility/snippets.html -->
<!-- Clone or save this code as js-switch.sublime-snippet into Data/Packages/User. No need to restart Sublime.
(If you Copy-Paste-SaveAs... with Sublime, be careful not to save as .xml. It's actually hard not to) -->
<!-- Use tabs in this file, not spaces -->
<snippet>
<content>
<![CDATA[switch (${1:expression}) {
case ${2:1}:
${3:f1()};
break;
case ${4:2}:
${5:f2()};
break;
case ${6:3}:
${7:f3()};
break;
default:
${8://tab to get here};
}]]>
</content>
<!-- Set a tabTrigger: how to trigger the snippet -->
<tabTrigger>switch</tabTrigger>
<!-- Optional: Set a description for the tabTrigger -->
<description>switch...case...</description>
<!-- Optional: Set a scope to limit the file types where this snippet will trigger -->
<scope>text.html, text.plain, source.js</scope>
</snippet>
@ZYinMD
Copy link
Author

ZYinMD commented Mar 3, 2018

type "switch" to trigger

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