I want to create an snippet when triggered it will surround the given text. Currently my snippet is:
{ "Function Creator Helper": { "prefix": "_w", "body": [ "public function $TM_SELECTED_TEXT () {", " $1", "}", ], "description": "Creates a function given the text selection" } }
This results on:
What I do is:
_w
)This results on:
public function () { }
But I was expecting
public function person () { }
Any ideas on how can I make this snippet or how can I triggered it correctly?
You can toggle word wrap for the VS Code session with Alt + Z (macOS: Option (or Alt) ⌥ + Z ) or select View > Word Wrap from Menu.
See https://stackoverflow.com/a/48676522/836330 Your example will work, as of vscode v1.49, as you have it. Vscode snippets have been updated to "remember" your selected text even though you seemingly overwrite it with your snippet prefix.
Older answer:
You can use $TM_SELECTED_TEXT
if you trigger it with a hotkey:
{ "key": "cmd+k 1", "command": "editor.action.insertSnippet", "when": "editorTextFocus", "args": { // "langId": "csharp", "name": "Function Creator Helper" } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With