Sublime Forum

Wrap selection in function using autocomplete

#1

Before discovering Sublime Text, I used TextMate and I had a snippet or plugin which provided the following functionality.

If you had a variable, or block of code selected and activated the shortcut (something like control+alt+w), it would wrap the selection in a “shell” function with autocomplete activated.

So essentially, if in PHP you wanted to change a variable to uppercase you could select the $variable, press ctrl+alt+w, then begin typing the php function’s name “strtoupper”, and once the function was selected you’d end up with a block of code similar to:

//original code
$a = $variable;

//after function wrap with "$variable" selected
$a = strtoupper($variable);

The closest I’ve found to this functionality is a very specific use case: stackoverflow.com/questions/1216 … th-snippet

Is it possible to recreate this functionality using a snippet?

Any help is appreciated, thanks!

0 Likes