I have created two snippets to work with Sublime Text. One is for working with HTML mode and another for working with JavaScript mode.
Go to the directory Data → Packages → User and create a file with the name of js_dw.sublime-snippet, attention here that the extension will be .sublime-snippet and the name you can keep what you wish. Please remember that I'm using a portable version of Sublime Text. If you use a .exe executable version go to Tools -> Developer -> New Snippet... See the screenshot- http://prntscr.com/oiosk5
Write the code into the file:
<snippet>
<content><![CDATA[document.write();]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>dw</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>text.html</scope>
<!-- Optional: Description to show in the menu -->
<description>JS Document Write</description>
</snippet>
Save it and restart your Sublime Text. Now turn your Sublime Text to HTML mode and write dw, then press Tab button. Here dw is a <tabTrigger> content. The CDATA content document.write(); will display. You can write anything on the CDATA block, that will appear after pressing the Tab button. Attention here in the <scope> block. I have written here text.html. The snippet will not work in JavaScript mode. It'll work in HTML, PHP and XML mode.
Just change the <scope>text.html</scope> to <scope>source.js</scope>. Now it will work on JavaScript mode. Hope that you have got the solution. If have any question or confusion, don't forget to drop a comment.
Go to the directory Data → Packages → User and create a file with the name of js_dw.sublime-snippet, attention here that the extension will be .sublime-snippet and the name you can keep what you wish. Please remember that I'm using a portable version of Sublime Text. If you use a .exe executable version go to Tools -> Developer -> New Snippet... See the screenshot- http://prntscr.com/oiosk5
Write the code into the file:
<snippet>
<content><![CDATA[document.write();]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>dw</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>text.html</scope>
<!-- Optional: Description to show in the menu -->
<description>JS Document Write</description>
</snippet>
Save it and restart your Sublime Text. Now turn your Sublime Text to HTML mode and write dw, then press Tab button. Here dw is a <tabTrigger> content. The CDATA content document.write(); will display. You can write anything on the CDATA block, that will appear after pressing the Tab button. Attention here in the <scope> block. I have written here text.html. The snippet will not work in JavaScript mode. It'll work in HTML, PHP and XML mode.
What you will do if you want to work with the JavaScript mode?
Just change the <scope>text.html</scope> to <scope>source.js</scope>. Now it will work on JavaScript mode. Hope that you have got the solution. If have any question or confusion, don't forget to drop a comment.
