"Snippet" is the meaning of "fragment" in English. When we encode, we usually want to hit a few short strings, and then come out with some fixed templates, which are similar to the front-end Zen coding.
However, at present, Sublime Text2 's Zen coding does not support, do not know sublime own built-in what default Sinppet, can only achieve some simple functions like Zen coding.
The definition is simple, and the new file is entered by tools->new snippets first.
The file includes the following content:
<snippet> <content><! [cdata[]]></content><!--optional:set a tabtrigger to define how to trigger the snippet--> ; <tabTrigger></tabTrigger><!--optional:set a scope to limit where the snippet would trigger -<scope></scope></snippet
Now the above parameters are explained:
- Content: is the template you want to define
- Tabtrigger: is the shortcut string you need to enter before you press the TAB key, after you lose the string, press the TAB key to generate the template content you want.
- Scope: is a limitation of the file format, for example, the HTML format to be set to text.html
The PHP example code is as follows:
<snippet>
<content><! [cdata[
Echo Json_encode (${1:\ $this}); exit (${2:1});
]]></content>
<!--Optional:set a tabtrigger to define what to trigger the snippet-
<tabTrigger>ej</tabTrigger>
<!--Optional:set a scope to limit where the snippet would trigger--
<scope>source.php</scope>
</snippet>
Then, save the file, rename the Ej.sublime-smippet code to enter the EJ return, you can display the following code:
echo Json_encode ($this); exit (1);
It is important to note that scope, because you do not know how to set, will let Sinppet normal response. Error setting, Nature is invalid.
Lists the scope list, as referenced from: https://gist.github.com/iambibhas/4705378:
ActionScript:Source.ActionScript.2AppleScript: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++OCamlCampl4:Source.Camlp4.OCamlOCaml:Source.OCamlOcamllex:Source.OcamllexPerl:Source.perlphp:Source.PhpRegular Expression(Python):Source.Regexp.PythonPython:Source.PythonrConsole:Source.R-Consoler:Source.RRubyOnRails:Source.Ruby.RailsRubyHAML:Text.Hamlsql(Ruby):Source.Sql.RubyRegular Expression:Source.RegexpRestructuredtext:Text.RestructuredtextRuby:Source.RubyScala:Source.ScalaShell Script:Source.Shellsql:Source.Sqltcl:Source.Tclhtml(tcl): Text.. Tclplain Text: Text.< Span class= "PLN" >plaintextile: Text.< Span class= "PLN" >html.: Text.: Text.. Xslyaml: Source.&NBSP;
Sublime Text Custom Snippet