Skip to content

Instantly share code, notes, and snippets.

@christianhanvey
Forked from harthur/snippet.md
Created July 2, 2012 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianhanvey/3030498 to your computer and use it in GitHub Desktop.
Save christianhanvey/3030498 to your computer and use it in GitHub Desktop.
console.log() key binding for Sublime Text

Go to Sublime Text 2 > Preferences > Key Bindings - User and add this JSON to the file:

[
    { "keys": ["super+shift+l"],
      "command": "insert_snippet",
      "args": {
        "contents": "console.log(${1:}$SELECTION);${0}"
      }, "context":
      [
        { "key": "selector", "operator": "equal", "operand": "source.js", "match_all": true }
      ]
    },
    { "keys": ["super+shift+l"],
      "command": "insert_snippet",
      "args": {
        "contents": "echo ${1:}$SELECTION; die(); ${0}"
      }, "context":
      [
        { "key": "selector", "operator": "equal", "operand": "source.php", "match_all": true }
      ]
    }

]

Inserts a console.log() at the current cursor position, tab once to jump past. Includes context support for different error logging based on language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment