emmetio / sublime-text-plugin

The essential toolkit for web-developers
https://emmet.io
MIT License
253 stars 29 forks source link

How to write a snippet for javascript? #168

Open BigTolly opened 3 years ago

BigTolly commented 3 years ago

For example, how to do this: "cl": "console.log(' $ ');" $ - cursor

Emmet.subling-settings: { "config": { "html": { "snippets": { "test": ".gg", // working "c": "{Hello}", // working } }, "css" : { "snippets" : { "pss" : "padding: 1px 2px 1px 2px;" // working } }, "markup" : { "snippets" : { "cl": "console.log();" // does not work } } } }

sergeche commented 3 years ago

It's better to use native Sublime Text snippets in your case. If you still want to create Emmet snippet, you should wrap custom text with {}, e.g. {console.log()}.

Emmet snippets are actually aliases for Emmet abbreviations, you define output structure with it

BigTolly commented 3 years ago

{ "config": { "html": { "snippets": { "cl": "{console.log();}, // it works in html } }, "css" : { "snippets" : { "cl": "{console.log();}, // it works in css } }, "markup" : { "snippets" : { "cl": "{console.log();}" // it doesn't work in js (javascript) } } } }

sergeche commented 3 years ago

Not sure what you mean. Emmet doesn't work in JS by default, only in JSX with prefixed mode: https://github.com/emmetio/sublime-text-plugin#jsx-support

BigTolly commented 3 years ago

OK, thanks.