So, I was following the approach to bind console.log function to shorter name. Here’s another technique which is specific to Sublime Text.
Using Sublime Text Snippets option, you can create a shortcut to a template and then you can insert that template in multiple places just by triggering the shortcut. Here’s how I did it so that every time, I type echo, Sublime Text converts it into console.log();
Go to Tools -> New Snippet. Sublime will open a template in a new file. Now make sure you have this content in that file (or change it the way you want).
<snippet> <content><![CDATA[ console.log( ]]></content> <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> <tabTrigger>echo</tabTrigger> --> <!-- Optional: Set a scope to limit where the snippet will trigger --> <scope>source.js</scope> </snippet>
Then save this snippet file as echo.sublime-snippet under Packages/User folder. To find the location of Packages/User folder, in Sublime, go to Preferences -> Browser packages and note the location.