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

144
Views
Add a for-loop to VSCode Snippet

I successfully created 3 VSCode snippets, I added the 4th one.

{
      "for": {
        "prefix": "for",
        "body": "for (i = 0; i < ${1:}.length; i++) {
            console.log(${1:}[i]);
        }"
      }

  }

IDE is highlighted as red, and I am not able to see it in the snippet list.

enter image description here

How can I fix that ?

Goal is to

As I type/select for should add this code. Hint: for is my snippet prefix.

for (i = 0; i < responses.length; i++) {
    console.log(responses[i]);
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I just went through the user defined snippets documentation and looks like you have to put the body content in an array. Can you please try this way :

{
  "for": {
    "prefix": "for",
    "body": ["for (const ${2:element} of ${1:array}) {", "\t$0", "}"]
  }
}
about 4 years ago · Juan Pablo Isaza Report

0

I found a working solution, I achived it by doing this:

"FOR": {
    "prefix": "for",
    "body": [
        "for (var i = 0; i < ${array}.length; i++) {",
        "\tconsole.log(${array}[i]);",
        "\t$0",
        "}"
    ]
}

Result

As I type

enter image description here

As I select

enter image description here

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!