简体   繁体   中英

User snippets not working in VScode

Hi guys I'm using VScode and trying to get some user snippets to work. I've tried adding them to both the javascriptreact.json file and the javascript.json file... and even the html.json file but with no success.

I know VSCode uses Emmet, and am confused as to whether user snippets work with emmet rather than intellisense, and if so am I putting this in the wrong file?

Cheers in advance for any help!

I am trying to overwrite the default div. span. img. etc. by adding the following snippets:

 "Expand ReactQL Div": { "prefix: "div.", "body": [ "<div className={css.:1}>:2</div>;" ], "description": "expand div" }, "Expand ReactQL img": { "prefix: "img.", "body": [ "<img src={:1} alt=":2" className={css.:3} />;" ], "description": "expand img" }, "Expand ReactQL span": { "prefix: "span.", "body": [ "<span className={css.1:}>:2</span>;" ], "description": "expand span" } 

I'd imagine you have solved this one, but for anyone else,

There a few issues with your snippets:

Missing " within your prefix definition, the : is also enclosed in quotes.

{css.:1} syntax works like so ${1:css}

An example:

"Expand ReactQL Div": {
    "prefix": "div.",
    "body": [
        "<div className=${1:css}>${2}</div>"
    ],
    "description": "expand div"
},

Demo of snippet in action

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM