New VS Code emmet snippets specifically tailored for .vue files

Exploring the capabilities of Emmet snippets in VS Code has been a game-changer for me, especially as I navigate my way around this new IDE. Despite my efforts to find an answer through Google, one question continues to elude me. After experimenting with adding Emmet snippets into my .vue files by tweaking my VS Code settings.json file like so:

"emmet.syntaxProfiles": {
    "vue-html":"html",
    "vue":"html",
}

While this approach worked seamlessly, I desired to incorporate a few custom snippets, prompting me to include this additional entry:

"emmet.extensionsPath": [
    "C:\\CodeSnippets"
],

Within one of these snippet files lies the following pertinent code block: {

"html": {
  "snippets": {
    "ull": "ul>li[id=${1} class=${2}]*2{ Will work with html, pug, haml and slim }",
    "oll": "<ol><li id=${1} class=${2}> Will only work in html </ol>",
    "vgc": "{ Wrap plain text in curly braces }",
    "ig": "{import ${1} from './${2:components}/${1}.vue'}"
  }
},
"css": {
  "snippets": {

  }
}

}

It's fascinating how typing oll within a '.html' file effortlessly injects the snippet, evident in the associated screenshot. https://i.sstatic.net/BkV3N.png

However, replicating the same action within a .vue file yields no results. Although Emmet functions properly in my .vue document for other tasks, as illustrated in the screenshot below: https://i.sstatic.net/C8Or5.png

I'm convinced that there must be some overlooked configuration on my end, but pinpointing it remains elusive. Any insights or suggestions would be greatly appreciated!

Answer №1

Have you been searching for this?

> Tips: Customize User Snippets

Next, choose

vue-html.json

Take a look at this JSON example

{
  "example snippet": {
    "prefix": "vvexample",
    "body": [
      "some ${1:example}"
    ],
    "description": "a sample snippet for the Vue template"
  }
}

https://i.sstatic.net/PVVAQ.png

Hit tab and see what happens

https://i.sstatic.net/iIlhV.png


PS: Remember that the ${1:example} part highlights 'example' for easy editing. You can also cycle through with $2 ... using tab.

Check out the official page for more information on this feature.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

NestJs is unable to utilize the pg library

I attempted to incorporate the below webpack configuration but unfortunately, it does not seem to be functioning as expected: import webpack from 'webpack'; module.exports = { webpack: (config, options) => { config.plugins.push( n ...

The integration of Ajax and Datatables to implement a CRUD table functionality is not functioning properly

I'm currently facing an issue while trying to display data in my CRUD table using Ajax + Datatables. I am able to retrieve the JSON response with the necessary data from my database, but for some reason, it's not getting displayed on the table. ...

Display unique data-id values for each list item when hovering with Jquery

I am designing a menu for my website where it will appear on the left side of the web. The menu will consist of X <li> items, each with an icon. When I hover over each <li>, I want to display X data-id associated with that item along with the i ...

Creating a Vue.js application with multiple pages in nested subdirectories through custom configurations in vue.config.js

I successfully created a multipage Vue.js application with functional pages on domain/legal, domain/submit, and more by utilizing Vue.js' pages feature (customizing vue.config.js). Now, I'm attempting to add nested pages under a new subdirectory ...

Increase counter when a field is filled out using jQuery

My goal is to implement a hidden contact form field that has a linked counter which increments by 1 as soon as it is filled in the source code. I have chosen the input function for this purpose, regardless of the number of characters entered. Once the inpu ...

Encountered an error while attempting to log in: TypeError: the property 'id' of null cannot be read

I am facing an issue with the login process, specifically getting a TypeError: Cannot read property 'id' of null error message. How can I debug and resolve this error? var cas = require('cas-client'); get_forward_url(function(forwardur ...

Manipulate JSON data in a Node.js loop

Currently, I am working on a monitoring system that will indicate on a website whether a server is up or down. I have experimented with various methods such as regex and replacement to modify the JSON file. My main objective is to dynamically change the "s ...

Stop AngularJS $http promise from fetching cached JSON data

During the signup process of my AngularJS application, I continuously update a user object. Instead of creating separate controllers for each signup step, I have opted to use one controller for all steps as the logic is quite similar and it helps keep the ...

Strange JSON.parse quirk observed in Node.js when dealing with double backslashes

My coworker encountered an issue while trying to parse a JSON string from another system, leading to unexpected behavior. To illustrate the problem, I have provided a simple code snippet below: // This code is designed for node versions 8 and above con ...

Just starting out with Angular - facing issues with setting up in eclipse

I'm attempting to create a test Angular project in Eclipse by copying the three files from the Angular website https://docs.angularjs.org/api/ng/directive/ngController into my Eclipse project. I initially created it as a static web project and then co ...

On the second attempt, Firefox is able to drag the div element smoothly by itself

I have created a slider resembling volume controls for players using jQuery. However, I am facing an issue ONLY IN FIREFOX. When I drag the slider for the second time, the browser itself drags the div as if dragging images. The problem disappears if I clic ...

Performing aggregation in MongoDB with nested subdocuments

I have a specific document structure as shown below: { "_id": "some_uuid", "inv": { "food01": "id01", "food02": "id02", "food03": "id03" }, " ...

Complete Form Validation Issue Unresolved by Jquery Validation Plugin

I'm facing an issue with the jQuery validation plugin while attempting to validate a form. Strangely, it only works for one input field. Can anyone suggest a solution? <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.valid ...

Can CSS actually generate accurate inches?

Can you accurately set the width of an element, like a div, in inches and expect it to maintain that width across different devices? Or will it simply scale at a ratio like 1in = 96px? Edit: Try using CSS to set an element's width in inches and then ...

What is the best way to extract the property name from the AJV output in order to effectively translate validation errors into user-friendly

I am currently utilizing the AJV library for input validation in my nodejs express api. I'm facing an issue with extracting the property name associated with each error object within the returned array. [{ instancePath: '', schemaPath: & ...

Utilize the Material UI feature to call the function

How can I pass a function as a prop to my Material UI component if the function is undefined within the component? import React, { Component } from 'react'; import styled from 'styled-components'; import InputBase from '@material- ...

Issue with Jquery - Variable not getting updated on resize event, causing multiple saves

After creating this jQuery script to enable/disable a fixed position div based on user scrolling behavior, I encountered an issue where the functionality breaks upon window resizing. Despite my attempts to update the variables correctly after resizing, the ...

ThymeLeaf fails to display the elements of a List

I am struggling with a complex HTML structure in my project. The HTML code includes a mix of Bootstrap classes and Thymeleaf attributes. Additionally, there is a JavaScript function that interacts with radio buttons to show or hide elements based on user i ...

Removing an object in Three.js using scene.getObjectByName() method

When developing my game, I encountered a challenge. I'm loading 4 different buildings and creating 15 clones of each within a for loop. These clones are then added to an array called masterBuildingArray, which I iterate through using a forEach loop. T ...

What could be causing this compatibility issue between IE and Chrome? It's strange that the Table is displaying correctly only in Chrome

Recently, I encountered a challenge with my code in Chrome and realized that it also needs to work in Internet Explorer. Can someone assist me in making it fully functional in IE? I suspect that there might be specific code adjustments needed for IE as th ...