Wrap Selection Snippet on Visual Studio Code (vscode)

后端 未结 6 1998
暖寄归人
暖寄归人 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:45

    ${TM_SELECTED_TEXT} does not work for me either.

    ${selectedText} has been added as a Snippet Editor Variable: https://github.com/Microsoft/vscode/pull/39483#issuecomment-383552677

    Example:

    "JS Block Quote": {
        "prefix": "c2",
        "body": [
            "/* ${selectedText} */",
        ],
        "description": "JS Block Quote"
    }
    

    At this time it is not correctly documented: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_variables

    NOTE: In a multi-line selection, ${selectedText} is truncated to the first line. An alternative is to use the the clipboard and the ${CLIPBOARD} variable. An extra step :(

提交回复
热议问题