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?
-
1The 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. =)J. Steen– J. Steen2014-06-12 14:24:57 +00:00Commented 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.J. Steen– J. Steen2014-06-12 14:31:22 +00:00Commented Jun 12, 2014 at 14:31
Add a comment
|
1 Answer
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