Sublime Debug Killer

Find debug statements unintentionally left behind in your code

Download as .zip Download as .tar.gz View on GitHub

Sublime Debug Killer - Global Config

Home Global Config Project Config

The Debug Killer plugin relies on a configuration file in the plugin directory called DebugKiller.sublime-settings. The settings found here tell the plugin what debug directives to look for based on what type of source files it is looking at. These settings can be overridden by creating a file by the same name in your Sublime User directory.

The settings file contains a key named patterns. This is a list (array) of the type of debug statements the plugin looks for. As an example the pattern that looks for the var_dump() method in PHP looks like this.

{
   "pattern": "var_dump\\(.*?\\)",
   "scopes": [
      "string.quoted.double.sql.php",
      "source.php.embedded.block.html",
      "source.sql.embedded.php",
      "text.html.basic"
   ]
}

Patterns and Scopes

Each pattern must be in a dictionary (object) and contain two keys: pattern and scopes. The pattern key is regex that defines what the plugin looks for. The scopes key is a list (array) of Sublime scopes that this pattern applies to.

So let's talk scopes for a minute. Each type of language Sublime supports, be it built in or installed through a plugin, has one or more scopes associated with it. For example if you wanted to provide a pattern for debug statements in the Clojure language you would need to know the scope to attach it to.

The easiest way to find the scope of a language in Sublime is to open its tmLanguage definition. In the Clojure example you would find this in your Packages directory in the Clojure subdirectory in a file named Clojure.tmLanguage. If you open that file and search for <key>scopeName</key>. When you find that look at the line below it. You should find text that contains source.clojure. That is the scope name.


Example

Let's see what a Clojure pattern would look like that looks for a method named logme() (notice that this is fake, not real).

{
   "pattern": "logme\\(.*?\\)",
   "scopes": [
      "source.clojure"
   ]
}

Next >>