片段变量? [英] Snippet Variables?

查看:34
本文介绍了片段变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在 Atom 中创建带有变量的片段(就像 Emmet 在 HTML 中所做的那样)?

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:

来自:p4

至:填充:4% 4% 4% 4%

( From: p[i] 到 padding: i% i% i% i% ) (用户输入 p+[i]> , i 是变量 )

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

推荐答案

据我所知,您无法使用 Atom 代码段做到这一点,因为它们仅由 CSON 组成(即没有脚本).因此,虽然您不能这样做,但您可以使用单个变量并将其扩展到代码段中的多个位置,我在此博客中了解到的一些内容是我阅读 这里

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

取自那篇文章,这里是 CSON 的例子:

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;'

看看它,您似乎还可以通过 Tab 键浏览每个占位符来编辑需要不同的任何填充.

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

这篇关于片段变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆