" I want to work this function like th" /> " I want to work this function like th" /> " I want to work this function like th"/>

How to bind a key for selected text in Sublime Text?

280 Views Asked by At

So I have a text for example "this is sample text" and I want it to become this "<![CDATA[this is sample text]]>"

I want to work this function like this: I select any text and use hotkey like ctrl+t or so.

I use Sublime Text 3.

How can I do this for the selection of text?

1

There are 1 best solutions below

1
Keith Hall On

You can create a new keybinding to use the insert_snippet command to wrap your selection. (Preferences menu -> Keybindings)

{ "keys": ["ctrl+t"], "command": "insert_snippet", "args": {"contents": "<![CDATA[${0:$SELECTION}]]>"}, "context":
    [
        { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true },
    ]
},