<snippet>
<content><![CDATA[
<?php echo __( '${1:${SELECTION/'/\\'/g}}' ) ?>
]]></content>
<tabTrigger>i18n</tabTrigger>
</snippet>
save code above to file
Data/Packages/User/i18n.sublime-snippet
{ "keys": ["ctrl+shift+8"], "command": "insert_snippet", "args": { "name": "Packages/User/i18n.sublime-snippet" } },
If you want to have more hints while creating new snippets, create new Plugin with following code:
NewSnippetCommand.py
import sublime, sublime_plugin
import os
class NewSnippetCommand(sublime_plugin.WindowCommand):
def run(self):
v = self.window.new_file()
v.settings().set('default_dir',
os.path.join(sublime.packages_path(), 'User'))
v.settings().set('default_extension', 'sublime-snippet')
v.set_syntax_file('Packages/XML/XML.tmLanguage')
template = """<snippet>
<content><![CDATA[
${1:Hello, \${1:some default text\} in a \${2:snippet\}.\$3}
]]></content>
<!-- just cursor positions \$1 and \$2 -->
<!-- \${1:some default text} -->
<!-- \${1:\$SELECTION} -->
<!-- \${1/(.*)/\u\$1/} -->
<!-- \${1/'/\\\\\\'/g} -->
<!-- \${1/./=/g} -->
<!-- \${1:\${SELECTION/'/\\\\\\'/g}} -->
<!-- \${1/([[:upper:]]+)/(?1_\l\$1:)/g} -->
<!-- \${1/(.*)/\u\$1/} cannot be empty, \${1:$SELECTION} is required -->
<!-- max="\${2:50}", maxMessage="\${1:$SELECTION} is too long. It should have {{ \${2:\$2} }}... -->
<!-- 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>
"""
v.run_command("insert_snippet", {"contents": template})