Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables of VSC snipped are ignored using macro #47

Open
ottopic opened this issue Jan 21, 2019 · 1 comment
Open

Variables of VSC snipped are ignored using macro #47

ottopic opened this issue Jan 21, 2019 · 1 comment

Comments

@ottopic
Copy link

ottopic commented Jan 21, 2019

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
Copy link

ctf0 commented May 11, 2019

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

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants