3

I'd like to create a custom keybinding on ST3 so that whenever I highlight an element or my cursos is next to it, it surrounds it with a predefined text.

Something that would look like that

{
"keys": ["ctrl+shift+m"], "command": "insert_snippet"
,"args": {"contents": "text before", "text after"}
}

So that: file.js

becomes: text before file.js text after

Any help will highly be appreciated.

Jean Henry
  • 436
  • 4
  • 14

1 Answers1

2

If the text that should be inserted after and before the selection is always the same you can use the $SELECTION variable:

{ "keys": ["ctrl+shift+m"], "command": "insert_snippet", "args": {"contents": "BEFORE_TEXT ${SELECTION} AFTER_TEXT"} }
sergioFC
  • 5,926
  • 3
  • 40
  • 54
  • Thank you sergioFC, your solution is fine, I managed to tweak it to my preferences with some documentation :) – Jean Henry Jan 19 '15 at 08:55