[英]Can i add css property shortcuts to sublime text?
Can I add more shortcuts like this one to SublimeText? 我可以在SublimeText中添加更多这样的快捷方式吗?
Like one that is "ma"
that will expand to margin: 0 auto;
就像一个
"ma"
将扩展到margin: 0 auto;
? ?
I apologize if this has already been asked. 如果已经有人问我,我道歉。 I couldn't find the answer.
我找不到答案。
These are called snippets . 这些被称为片段 。 For this particular example, Open the
Tools
menu and select New Snippet...
, then paste in the following: 对于此特定示例,请打开“
Tools
菜单并选择“ New Snippet...
,然后粘贴以下内容:
<snippet>
<content><![CDATA[margin: 0 auto;]]></content>
<tabTrigger>m-a</tabTrigger>
<scope>source.css</scope>
</snippet>
Save this file as Packages/User/CSS/margin auto.sublime-snippet
and you should be good to go. 将此文件另存为
Packages/User/CSS/margin auto.sublime-snippet
,您应该好好去。 Open a CSS file, type ma
, hit Tab , and you're all set. 打开一个CSS文件,输入
ma
,点击Tab ,然后你就完成了。 Snippets are pretty powerful, and also allow for tab stops to enter customized data. 片段功能非常强大,还允许制表位输入自定义数据。 For example, you could set up some boilerplate code that only requires that the colors be customized like so:
例如,您可以设置一些样板代码,只需要像这样定制颜色:
<snippet>
<content><![CDATA[body {
max-width: 500px;
_width: 500px;
padding: 30px 20px 50px;
border: 1px solid ${1:#b3b3b3};
border-radius: 4px;
margin: 0 auto;
box-shadow: 0 1px 10px ${2:#a7a7a7}, inset 0 1px 0 ${3:#fff};
background: ${4:#fcfcfc};
}
$5
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>setbody</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.css</scope>
</snippet>
When you hit Tab to trigger the snippet, the #b3b3b3
in the border
property is highlighted, ready to be edited. 当您按Tab键触发片段时,
border
属性中的#b3b3b3
会突出显示,可以进行编辑。 When you're done, hit Tab again to go to the first color definition in box-shadow
, etc. The final Tab leaves you outside the brackets, ready for your next selector. 完成后,再次按Tab键转到
box-shadow
的第一个颜色定义等。最后一个选项卡会将您留在括号内,为下一个选择器做好准备。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.