Wrote a sublime template plugin, project home: Https://github.com/kairyou/SublimeTmpl
This allows you to use the content of the template when creating a new file, and now adds the Html/js/css/php/python/ruby template. You don't need to create a new blank file, and then copy the content from another file.
Support for sublime Text3 has been increased.
Use:
1. St Menu, file-new file (Sublimetmpl), select the corresponding menu in the list, you can use the template to create new files directly.
2. Command, Cmd+shift+p, enter: "Tmpl:", you can find the menu list to create the file.
3. Shortcut keys, see below for default shortcuts. You can modify it yourself by seeing the "Settings" section.
Default shortcut keys:
- CTRL+ALT+h html
- CTRL+Alt+j JavaScript
- CTRL+Alt+c CSS
- CTRL+alt+p PHP
- CTRL+Alt+r Ruby
- CTRL+ALT + +shift+p python
Installation:
Method 1. Through the package Control
Package Control/install, search for "Sublimetmpl" or "Tmpl", install.
* [2012/08/01] has passed the package control audit
Method 2. Github
Open the Project home page, git clone to St's Packages folder (\data\packages), or download the zip file directly to the Packages folder (the folder name must be: Sublimetmpl).
Set up:
Menu: Preferences/packages settings/sublimetmpl, can Edit menu/shortcut/new syntax and so on.
If you would like to contribute your own package, you can refer to my introduction to this post:
http://www.fantxi.com/blog/archives/how-to-submit-a-sublime-package/
New features:
1. User-defined templates (Thanks @Xu Cheng)
Custom template path: "data\packages\user\sublimetmpl\templates" directory, will be used first (can refer to: the default template).
Default template path: "Data\packages\sublimetmpl\templates" directory.
using your own custom template : It is recommended to copy the default template directory's *.tmpl file to the custom templates path and then modify it.
2. Template supports ${date} variables
Settings-user inside can modify ${date} default output Format ("%y-%m-%d%h:%m:%s"), such as: "Date_format": "%y-%m-%d"
3. Templates support Custom attr
Added in Settings-user:
-
"attr": {
-
" Author": "Your name" ,
-
" Email": "[email protected]",
-
" link": "http://yours.com",
-
"Hello": "word"
-
}
You can use ${author} ${email} ${link} ${hello} variables in the template
Thanks @vfasky (Blog)
In addition, additional instructions on the new language
1. New language not in Sublimetmpl
First look at: Packages Settings/sublimetmpl/settings-default's default syntax setting.
If you want to add syntax, select: sublimetmpl/settings-user, Content format reference Settings-default content, such as two new language test and yours:
- {
- < Span class= "PLN" > "test" : { "syntax" : },
- "Yours" Span class= "pun" >: { "syntax" : "packages/yours/yours.tmlanguage" }
-
The above "Packages/test/test.tmlanguage" is the syntax path within the Packages directory, and the file must exist before it can be valid.
New Start Menu: You can add test and yours in Sublimetmpl/settings-menu with reference to other syntax.
New shortcut key: Can edit: Sublimetmpl/key Bindings User (format reference: Sublimetmpl/key Bindings Default)
2. New language for Sublime
I don't have a new one, I can go to the package control or GitHub to find someone else to add a new language, reference.
If you do not find someone else to write well, you can refer to the following Web site, do it yourself:
http://docs.sublimetext.info/en/latest/extensibility/syntaxdefs.html (official documentation, made with Aaapackagedev this plugin)
Http://manual.macromates.com/en/language_grammars (TextMate doc, and Sublime are mostly the same)
Https://github.com/LearnBoost/stylus/blob/master/editors/Stylus.tmbundle/Syntaxes/Stylus.tmLanguage (Someone else writes good grammar, Can be compared with their own new)
Turn from Kairyou's Blog http://www.fantxi.com/blog/archives/sublime-template-engine-sublimetmpl/
Sublime Text New File template plugin: Sublimetmpl