Sublime Forum

Custom string wrappers

#1

Hello! I would like to create some custom string wrappers. For example:

this is some text

I would like to be able to select part or all of the string and then hit a combo of keys and the selected text is wrapped:

this is some {% trans 'text' %}

How is this done in Sublime?

0 Likes

#2

You can use the autopair keybindings as an example.

{ "keys": <your key combo>], "command": "insert_snippet", "args": {"contents": "\"${0:$SELECTION}\""} },

Rather than escaped quotes, wrap it with what you want. Just ensure the “$SELECTION” is in there.

0 Likes

#3

Thank you very much! That fills a gap in my sublime knowledge!

0 Likes