Skip to content

Instantly share code, notes, and snippets.

@select
Created February 6, 2015 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save select/e5a4e35e02f072d2fdde to your computer and use it in GitHub Desktop.
Save select/e5a4e35e02f072d2fdde to your computer and use it in GitHub Desktop.
Sublime Text replace selected text with a snippet, trigger this with a keyboard shortcut (e.g. for wrapping natural laguage strings with a call to a translation function)
// add this to your "Key Bindings - User" to trigger the snipped
{
"keys": ["ctrl+1"],
"command": "insert_snippet",
"args": {
"name": "Packages/User/php-translation-wrap-string.sublime-snippet"
},
}
<!-- this snipped will wrap the selected text -->
<snippet>
<content><![CDATA[
' . \$this->translate('${0:$TM_SELECTED_TEXT}') . '
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>translate wrap string</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.php</scope>
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment