10

I've made own user snippet code for javascript

"inner backquote concat variable" : {
 "prefix": "$",
 "body": "\\${1ドル}",
 "description": "concat variable with backquote sting"
}

I want that snippet to work inside backquote string or single quote string when I press '$' like this

snippetwork.gif

but it does not work when inside a string.

heloquote.gif

How do make the snippet work inside a string?

Mark
191k32 gold badges555 silver badges577 bronze badges
asked Sep 19, 2019 at 10:21

2 Answers 2

13

Add the following snippet in settings.json

"editor.quickSuggestions": {
 "strings": true
 },

It makes all snippets/emmets working on strings.

Naveen DA
4,3986 gold badges43 silver badges62 bronze badges
answered Sep 19, 2019 at 10:33
Sign up to request clarification or add additional context in comments.

Comments

2

Together with @Ridwan's suggestion your example still wouldn't work because you have no space between $ and the backtick - so vscode does not see the $ as your prefix, it is just part of a larger string and so doesn't look like a unique trigger it is expecting.

You can see this with any snippet in or out of a string (using your snippet):

snippet prefix demo

So the snippet prefix must "stand alone" so to speak so it can be recognized as a separate trigger. And that includes not being next to a " or backtick. They must have spaces around them.

answered Sep 19, 2019 at 14:05

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.