Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
Execute function in vscode snippet

Is it possible to run a function during expansion of snippet?

javascript.json - vscode snippet file:

function add() {
    return 2+2;
}

"Print to console": {
    "prefix": "log",
    "body": [
        "console.log("Addition", add());"
    ],
    "description": "Log output to console"
}

index.js - project file:

// I wrote "log" and intellisense currently provides
console.log("Addition", add());

// But I need
console.log("Addition", 4);

The obvious reason might be snippet is a json file, it's not a javascript file so it can't run code, just show syntax as it with cursor positions $1, $2 etc.

Or is it possible through a vscode plugin?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Using Hypersnips vscode extension as suggested by rioV8, I've a working hsnips which might help you.

all.hsnips OR javascript.hsnips:

global
function add() {
  return 2+2;
}
endglobal

snippet log "Log output to console"
``
rv = `console.log("Addition", ${add()})`
``
endsnippet
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!