Snippet Variables?

杀马特。学长 韩版系。学妹 提交于 2019-12-04 05:48:17

问题


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

To: padding: 4% 4% 4% 4%

( From: p[i] to padding: i% i% i% i% ) (the user input p+[i] , i is variable )


回答1:


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.



来源:https://stackoverflow.com/questions/41538042/snippet-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!