Snippet Variables?

前端 未结 1 667
余生分开走
余生分开走 2021-01-26 21:20

Is there any way that we can create snippets in Atom with variables (someway like Emmet did in HTML)?

Here\'s an example that we want to achieve:

From: p4<

相关标签:
1条回答
  • 2021-01-26 22:05

    To my knowledge you are not able to do that with Atom snippets because they are composed with just CSON (i.e. no scripting). So while you can't do that you can use a single variable and expand it into multiple locations in your snippet, something I learned in this blog that I read here

    Taken from that post, here is example CSON to do that:

    '.source.css':
       'Padding With Mostly Identical Values':
         'prefix': 'pwmiv'
         'body': 'padding: ${1:num}px ${1:num}$2px ${1:num}$3px ${1:num}$4px;'
    

    Looking at it, it looks like you can also tab through each placeholder to edit any paddings that need to be different.

    0 讨论(0)
提交回复
热议问题