Last Updated: February 25, 2016
·
434
· ncthis

A snippet for initializing debug on sublime text

I use debug pretty religously. This is an example initialisation:

const log = require('debug')('MyApp:FooFile.js:log');
const error = require('debug')('MyApp:FooFile.js:error');

But doing that for each FooFile.js manually is cumbersome at best. So, I use this snippet:

<snippet>
  <!-- Example: Hello, ${1:this} is a ${2:snippet}. -->
  <content><![CDATA[
const log = require('debug')('$TM_FILENAME:log');
const error = require('debug')('$TM_FILENAME:error');
]]></content>
  <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
  <tabTrigger>dbg</tabTrigger>
  <description>filename:debug</description>
  <!-- Optional: Set a scope to limit where the snippet will trigger -->
  <scope>source.js</scope>
</snippet>

And then you can do dbg (whatever's inside tabTrigger element), and then You have initiated logs!

Note: I originally published this here.