geddski / macros

macros support for VS Code
MIT License
165 stars 36 forks source link

Variables of VSC snipped are ignored using macro #47

Open ottopic opened 5 years ago

ottopic commented 5 years ago

Hello, I'm using macro to insert custom snippet from selected var in newline.

My snippet is:

    "customprintr": {
        "prefix": "customprintr",
        "body": [
            "\t \\$printMe = ${CLIPBOARD}; "
        ],
        "description": "Insert custom print_r"
    }   

and my macro is:

"macros": {
        "printr": [
            "editor.action.smartSelect.grow",
            "editor.action.clipboardCopyAction",
            "editor.action.insertLineAfter",
            {
             "command": "editor.action.insertSnippet",
                "args": {
                    "name": "customprintr",
                    "langId": "php",
                }
           },
        ]
    }, 

The problem is that after macro execution my clipboard is changed. My goal is obtain the same thing without change my clipboard, using for example ${TM_SELECTED_TEXT} in the snippet. I tried, but used with macro this variable is ignored.

Link to snippet variables https://code.visualstudio.com/docs/editor/userdefinedsnippets#_creating-your-own-snippets

Someone can help me?

ctf0 commented 5 years ago

what about

"customprintr": {
        "prefix": "customprintr",
        "body": [
            "\t \\$printMe = ${TM_SELECTED_TEXT}; "
        ],
        "description": "Insert custom print_r"
    }   
"macros": {
        "printr": [
            "editor.action.smartSelect.grow",
            {
             "command": "editor.action.insertSnippet",
                "args": {
                    "name": "customprintr",
                    "langId": "php",
                }
           },
           "editor.action.insertLineAfter",
        ]
    }, 

?