I'd like to create a key binding in Sublime Text 2 to place cursors at both ends of the selected text. For instance, if I bound this command to Ctrl+B, then selecting a word, hitting Ctrl+B, and pressing space would add a space on both sides of the word.

Is this possible?


I realize the answer as soon as I posted this: Just use a snippet which multiple instances of the cursor (represented by $1) around the selection:

{ "keys": ["ctrl+b"], "command": "insert_snippet", "args": {"contents": "$1${0:$SELECTION}$1"}, "context":
    { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.