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

142
Views
Cant figure out user snippets

I am trying to make another user snippet in VSCode to automate the document.querySelector but whenever I try to it gives me a weird error shown below. I have another snippet that works just fine but that was shown to me by an online class I am taking. I don't have any experience with json so I may just be getting the syntax wrong but it is the exact same as my previous snippet.

VSCode screenshot

In case that link doesn't work I'll include the code written below. The error I am getting is on the very first curly brace and it says "end of file expected .json"

All help is appreciated :)

{                    // start of file and json object

// other snippets here

  
  "query selector": {
    "scope": "javascript",
    "prefix": "dq",
    "body": ["document.querySelector('$0')"],
    "description": "Select element from document"
  },

// other snippets here

}                    // end of json object
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Use a square bracket to start a json file, and end with a square bracket [ ].

[
  {
  "query selector": {
  "scope": "javascript",
  "prefix": "dq",
  "body": 
  ["document.querySelector('$0')"],
  "description": "Select element from document"
                 }
  }
]
about 4 years ago · Juan Pablo Isaza Report

0

Your json file is incorrect.

You should place the object starting with the key “query selector” inside the json object above.

Add a comma after the curly brace in line 14 and add your snippet in there. Remove your outer curly braces from lines 17 and 24.

Json files are only one single object.

So your snippets file would look something like this:

{
  "Print to console": {
    "prefix": "log",
    "body": [
      "console.log('$1');",
      "$2"
    ],
    "description": "Log output to console"
  },
  "query selector": {
    "scope": "javascript",
    "prefix": "dq",
    "body": [
      "document.querySelector('$0')"
    ],
    "description": "Select element from document"
  }
}

By the way, I don't think you need the "scope" key.

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!