K
K
kobnuhok2021-07-01 10:02:55
Sublime Text
kobnuhok, 2021-07-01 10:02:55

How to edit emmet snippets in sublime text 3 win?

In sublime text 3 I put emmet
Bg+, I press Tab and the background color pops up, but I need background:url(' ') 0 0 no-repeat In sublime I set up a snippet, but it

doesn’t work on tab, but is highlighted for selection

Tab?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anatoly, 2021-08-26
@Tolly

https://github.com/emmetio/sublime-text-plugin
tools > Package Settings > Emmet > Settings

{
 "config": {
   	"html": {
     	"snippets": {
       	"test": ".gg",   // Если в html документе прописать .gg [Tab] то получим <div class="gg></div>
       	"c": "{Приветик}",  // с [Tab] напишет Приветик
       	"foo": "ul.foo>li.foo-item*4" // foo [Tab] тут уже посложнее выведет
      }
    },
    "css" : {
      "snippets" : {
        "pss" : "padding: 1px 2px 1px 2px;",   // Если в css документе прописать pss [Tab] выведет padding: 1px 2px 1px 2px;
       }
    }
  }
}

For js and not only, you can use the built-in snippet:
Tools > Developer > New Snippet
<snippet>
  <content>background:url(' ') 0 0 no-repeat</content> // Что
  <tabTrigger>bg+</tabTrigger> // Сокращение
        <scope>source.css</scope> // Где вызывается, сейчас во всех css файлах
</snippet>

Next, save the snippet in a file, for example:
bg.sublime-snippet

S
Sergey Erdyneev, 2021-11-20
@elserh

In Sublime Text 4, there is no "bg+" in the Emmet package, but there is a solution:
0. First close Sublime Text 4 (this is a must)
1. Go to the %appdata% folder (use search and type in the query including %)
2. Then ~\Roaming \Sublime Text\Installed Packages
3. Open the package "Emmet.sublime-package" using the WinRAR archiver (DO NOT unzip)
4. In the package, open the file along the path \emmet\snippet\scss.py (you can open it with a subline)
5. In file will have a list of snippets and on line 63 add:
"bgu": "background:url('${0}') 0 0 no-repeat",
Instead of bg+, you will use bgu, the "+" option does not work, checked (probably soon there will be a video on YouTube), but it can be added separately, via Tools->Developer->New Snippet
6. Reload Sublime Text

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question