10

How do I set a shortcut for inserting console.log() and wrapping it around my current selection in Sublime Text without installing any plugin or extra third-party stuff?

2
  • 1
    The question itself (without the answer) isn't quite clear on what you mean. If you rephrase to something asking about how to insert a snippet of text (with console.log() as an example) using a keyboard shortcut in Sublime Text it might be more useful to everyone. =) Commented Jun 12, 2014 at 14:24
  • I've given a crack at editing as well. If you feel this wasn't an improvement, feel free to change it. Commented Jun 12, 2014 at 14:31

1 Answer 1

21

So I found the answer. Thought I'd add it here for others:

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

[
    { "keys": ["alt+d"],
      "command": "insert_snippet",
      "args": {
        "contents": "console.log(${1:}$SELECTION);${0}"
      }
    }
]

Inserts a console.log() at the current cursor position on pressing alt+d.

Reference: https://gist.github.com/harthur/2951063

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.