Overview example of inserting a snippet
See original GitHub issueI tried to get your example of inserting a snippet within a macro to work without success. From VSCode extensions marketplace : macros. Your example:
And I have a macro that will select the word at my cursor, copy it, drop to a new line, and run that snippet to log the variable:
editor.action.addSelectionToNextFindMatch
`"macros": {
"logCurrentVariable": [
"editor.action.addSelectionToNextFindMatch",
"problems.action.copy",
{"command": "type", "args": {"text": "con"}}
]
}`
At the very least that must be missing an “insertSnippet” command? And there is no copy or paste? And the weird mention of “editor.action.addSelectionToNextFindMatch” seems out of place.
Might I suggest:
"logCurrentVariable": [
"editor.action.smartSelect.grow",
"editor.action.clipboardCopyAction",
"editor.action.insertLineAfter",
{
"command": "type",
"args": {
"text": "log"
}
},
"insertSnippet",
"editor.action.clipboardPasteAction"
]
which uses the following snippet (in VSCode) 👍
"Print to console": {
"prefix": "log",
"body": [
"console.log('${TM_FILENAME}, line ${TM_LINE_NUMBER} : $1 = ' + $1);"
],
"description": "Log output to console"
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:8
Top Results From Across the Web
Introduction to Snippets - Iterable Support Center
Snippets are reusable content blocks that you can add to your templates to ... This is the content that will be inserted in...
Read more >Snippets in Visual Studio Code
Snippets in Visual Studio Code. Code snippets are templates that make it easier to enter repeating code patterns, such as loops or conditional-statements....
Read more >Create and use snippets - Knowledge Base - HubSpot
Enter a name for the snippet shortcut in the Shortcut field. This shortcut will be used to insert the snippet in a record,...
Read more >Creating and Inserting Snippets - MadCap Flare's Online Help
How to Insert a Snippet · In the Content Explorer, double-click Introduction. · Click at the end of the Introduction heading and press...
Read more >An overview of Code Snippets in SSMS - SQLShack
Insert Code Snippets ... We use code snippets for quickly writing queries without any syntax errors. It is like a code template that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah! had the args to
editor.action.insertSnippet
wrong. Finally, this works:Change to
"editor.tabCompletion": true
and it works perfectly