question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Overview example of inserting a snippet

See original GitHub issue

I 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:open
  • Created 6 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

1reaction
lastobeluscommented, Dec 7, 2018

Ah! had the args to editor.action.insertSnippet wrong. Finally, this works:

    {
        "command": "editor.action.insertSnippet",
        "args": {
            "name": "colo",
            "langId": "javascript",
        }
    },
1reaction
LeThiHyVongcommented, Dec 6, 2017

Change to "editor.tabCompletion": true and it works perfectly

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found