11

I'd like to be able to edit default behaviour of "!" instead of creating my own version of "!" from scratch.

Is it possible to edit (tweak) default behaviours of Emmet abbreviations in VSC?

Morfidon
  • 1,469
  • 1
  • 18
  • 34
  • 1
    Yes but when you update VSC your edits are lost, best to use [custom emmet snippets](https://code.visualstudio.com/docs/editor/emmet#_using-custom-emmet-snippets) – rioV8 Jun 09 '21 at 09:52
  • just copy the definition of `!` to a custom snippet, use a different name, and modify the snippet – rioV8 Apr 16 '22 at 11:52

1 Answers1

0

Yes! From the docs:

Custom Emmet snippets need to be defined in a json file named snippets.json. The emmet.extensionsPath setting should have the path to the directory containing this file.

{
  "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>",
      "ran": "{ Wrap plain text in curly braces }"
    }
  },
  "css": {
    "snippets": {
      "cb": "color: black",
      "bsd": "border: 1px solid ${1:red}",
      "ls": "list-style: ${1}"
    }
  }
}

More info here.

You can also modify existing blocks using filters.

Tim
  • 2,843
  • 13
  • 25
  • 2
    Can you show a working example how to use filter on for example built-in "!"? – Morfidon Jun 14 '21 at 09:40
  • @Morfidon You can't write new filters and they only modify the output of emmet not the input string – rioV8 Apr 16 '22 at 11:49
  • what is the info value of copying the text of the link I mention in a comment – rioV8 Apr 16 '22 at 11:51
  • @riov8 - I never saw your comment, but even if I did, [per the Stack Exchange meta](https://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers/8259#8259) "links are fantastic, but they should never be the only piece of information in your answer." Link rot is a huge issue, and it's a long page, so picking out the specific example and adding other info is helpful. – Tim Apr 23 '22 at 19:35
  • if the link is dead VSC is also dead and it is the official doc of VSC not some geekforgeeks – rioV8 Apr 23 '22 at 19:41
  • Not actually true. Companies reorganize docs all the time. – Tim Apr 23 '22 at 23:50