Wrap Selection Snippet on Visual Studio Code (vscode)

后端 未结 6 1997
暖寄归人
暖寄归人 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 07:06

    If somebody wants to know, it works like that for me :

    I created two same snippet which only matches when I'm in html or php file (just create two snippets files in your snippets folder "php.json" and "html.json" it works for any languages) and added this code inside :

       "unicommentary": {
            "prefix": "unicommentary",
            "body": " ${0}",
            "description": "Creates a universal comment to disable both html and php."
        }
    

    The ${TM_SELECTED_TEXT} tag works when you select some text and trigger your snippet by the Insert Snippet command, you can't just write on selected text.

    When you want to use this, select the text you want in your snippet, press Ctrl + Shift + P and select Insert snippet then, type the name of your snippet, press enter and there you go !

提交回复
热议问题