打开tools-new snippet..
<snippet>
<content><![CDATA[Hello, ${1:this} is a ${2:snippet}.]]></content> <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> <!-- <tabTrigger>hello</tabTrigger> --> <!-- Optional: Set a scope to limit where the snippet will trigger --> <!-- <scope>source.python</scope> --></snippet>content里面写上你定义的代码段
tabTrigger里面写上你的快捷键
scope里面是你要为什么格式的文件设置快捷键,有如下选项:
ActionScript: source.actionscript.2
AppleScript: source.applescriptASP: source.aspBatch FIle: source.dosbatchC#: source.csC++: source.c++Clojure: source.clojureCSS: source.cssD: source.dDiff: source.diffErlang: source.erlangGo: source.goGraphViz: source.dotGroovy: source.groovyHaskell: source.haskellHTML: text.html(.basic)JSP: text.html.jspJava: source.javaJava Properties: source.java-propsJava Doc: text.html.javadocJSON: source.jsonJavascript: source.jsBibTex: source.bibtexLatex Log: text.log.latexLatex Memoir: text.tex.latex.memoirLatex: text.tex.latexTeX: text.texLisp: source.lispLua: source.luaMakeFile: source.makefileMarkdown: text.html.markdownMulti Markdown: text.html.markdown.multimarkdownMatlab: source.matlabObjective-C: source.objcObjective-C++: source.objc++OCaml campl4: source.camlp4.ocamlOCaml: source.ocamlOCamllex: source.ocamllexPerl: source.perlPHP: source.phpRegular Expression(python): source.regexp.pythonPython: source.pythonR Console: source.r-consoleR: source.rRuby on Rails: source.ruby.railsRuby HAML: text.hamlSQL(Ruby): source.sql.rubyRegular Expression: source.regexpRestructuredText: text.restructuredtextRuby: source.rubyScala: source.scalaShell Script: source.shellSQL: source.sqlTCL: source.tclHTML(TCL): text.html.tclPlain text: text.plainTextile: text.html.textileXML: text.xmlXSL: text.xml.xslYAML: source.yaml示例:
<snippet>
<content><![CDATA[/****Author:*Depends:*Created:*Last updated:*Copyright 2013 loveming.org*/]]></content> <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> <tabTrigger>/**</tabTrigger> <!-- Optional: Set a scope to limit where the snippet will trigger --> <scope>source.js</scope> <scope>text.js</scope></snippet>使用方式:
在以.html或者.js结尾的文件中,输入/**,然后按下tab即可!