37887

how to make user snippets work inside strings: vscode

<h3>Question</h3>

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

but it does not work when inside a string.

How do make the snippet work inside a string?


<h3>Answer1:</h3>

Add the following snippet in settings.json

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

It makes all snippets/emmets working on strings.


<h3>Answer2:</h3>

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):

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.

来源:https://stackoverflow.com/questions/58008872/how-to-make-user-snippets-work-inside-strings-vscode

Recommend

  • Current way of importing in a mixed Objective-C / Swift project
  • Optimising HDF5 dataset for Read/Write speed
  • Grid on top of Google maps produces gaps in squares
  • r - insert row for missing monthly data and interpolate
  • How to properly create a RollingFileAppender with AppenderComponentBuilder in log4j 2
  • Setting up rails dev env
  • Contact us email sending is not working in codeigniter php
  • Switching backgrounds, while switching text
  • Python 3.7 Docker images
  • Nested iframe cross-domain communication
  • Missing App Store icon codename one build
  • Is there a way to remove a script from a doc (using the new doc embedded script)
  • Migrating MOSS 2007 from SQL 2000 to SQL 2005 [closed]
  • Accessing parent namespace inside a Shiny Module
  • Parallelization via JDBC - Pyspark - How does parallelization work using JDBC?
  • remove date from DateTimePicker for Compact Framework
  • iPhone SDK Add Image to the Body of an Email?
  • JQuery Validate plugin submitting when it shouldn't
  • Is there a way to run c# forms application without showing a gui window (like a console application)
  • Send HTML Mail with Unicode
  • Generate a runnable jar and include libraries in it with Maven
  • jQuery Ajax call to WCF service returning “Method not allowed (405)”
  • How do I set the logging properties in a spring java configuration?
  • Magento-Change Attribute of All Products
  • Set SelectedIndex of ListView in FlipView_SelectionChanged event
  • Find angle of point on circle
  • Can I read another applications memory?
  • How to define something in JavaScript [closed]
  • Neo4j…how to get a visual representation of my data?
  • Geokit in Ruby on Rails, problem with acts_as_mappable
  • How to integrate angular2-material (alpha 8.2) with angular2-Quickstart app
  • Send array to next viewcontroller iOs xcode [duplicate]
  • Comma decimal separator is ignored by ASP.NET MVC model binder
  • Bitrate JWplayer
  • Accessing Arguments, Workflow Variables from custom activities
  • Running R's aov() mixed effects model from Python using rpy2