Wrap Selection Snippet on Visual Studio Code (vscode)

后端 未结 6 2029
暖寄归人
暖寄归人 2020-12-31 06:33

I want to create an snippet when triggered it will surround the given text. Currently my snippet is:

{ 
  \"Function Creator Helper\": {
    \"prefix\": \"_w         


        
6条回答
  •  情深已故
    2020-12-31 06:54

    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"
      }
    }
    

提交回复
热议问题