How to create snippets in sublime ?

By Hardik Savani | March 26, 2016 | | 1612 Viewer | Category : Sublime


nowdays sublime is a very popular text edir in the developing field. sublime text editor is provide lots of packages like code formatter, php syntax etc. sublime is also provide snippet. snippet is very intrsting point because if you need to write same code lots of time than you can create shortcut name for that command content. For example if you want to write text "lorem ipsum" then you can just write just "lorem" and get whole lorem text. In following example i create snippet "debug" for debug code of PHP.

If you write just "debug" you can find autocomplete with debug snippet and just click on it and find follwing code.

Name Of Snippet

debug

Snippet Result

echo "<pre>";print_r(this);exit;

First Click on "tools" on menubar and click at last "New snippet..." then can see new file open and put following code.

Snippet Code

<snippet>

<content><![CDATA[

echo "<pre>";print_r(${1:this});exit;

]]></content>

<tabTrigger>dbug</tabTrigger>

<!-- 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>

and save name should "dbug.sublime-snippet" and then write "dbug" on your php file and try this....