Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to write a snippet for javascript? #168

Open
BigTolly opened this issue Aug 26, 2021 · 4 comments
Open

How to write a snippet for javascript? #168

BigTolly opened this issue Aug 26, 2021 · 4 comments

Comments

@BigTolly
Copy link

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
Copy link
Member

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
Copy link
Author

{
"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
Copy link
Member

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
Copy link
Author

OK, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants