Sublime使用代码段的文本换行选择 [英] Sublime Text wrap selection with snippet
问题描述
我一直在挖掘Sublime的代码片段,插件和宏,但我似乎找不到我要找的。
I've been digging into Sublime's snippets, plugins and macros, but I can't seem to find what I'm looking for.
我试图改变这种情况:
.content {
color: @blue;
}
进入:
.content {
color: darken(@blue, 5%);
}
理想情况下,我可以选择 @blue
部分,命中命令,并正确包装整个东西。
Ideally, I'd be able to select the @blue
part, hit a command, and wrap the whole thing properly.
有什么想法吗?这是可能吗?
Any ideas? Is this even possible?
推荐答案
可以看到此处:
工具 - >新片段... - >另存为 darken.sublime- snippet
在 Data\Packages\User\
Tools -> New Snippet... -> save as darken.sublime-snippet
in Data\Packages\User\
<snippet>
<content><![CDATA[darken($SELECTION, 5%);]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>darken</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.css</scope>
<!-- Optional: Description to show in the menu -->
<description>Darken Snippet</description>
</snippet>
并且keybind:
{ "keys": ["ctrl+shift+o"],
"command": "insert_snippet",
"args": { "name": "Packages/User/darken.sublime-snippet" } },
EDIT:
如果你在 $ SELECTION
之后添加 $ 1
,那么光标将跳转到
It would be even better if you add $1
right after the $SELECTION
, then the cursor will jump to the selected word or right in the place where it has to be written if it's not selected.
将以上代码段的第二行更改为:
Change the above snippet's second line to this:
<content><![CDATA[darken($SELECTION$1, 5%);]]></content>
这篇关于Sublime使用代码段的文本换行选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!