代码段变量? [英] Snippet Variables?

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

问题描述

有什么方法可以在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

收件人:padding: 4% 4% 4% 4%

(从:p[i]到填充: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;'

看起来,您似乎也可以通过每个占位符来制表,以编辑需要不同的填充.

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天全站免登陆