在另一个代码片段内部时,如何展开一个代码片段?

编程入门 行业动态 更新时间:2024-10-27 03:33:26
本文介绍了在另一个代码片段内部时,如何展开一个代码片段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Sublime Text 3中,我试图在一个代码段内插入一个代码段,又名

In Sublime Text 3, I'm trying to insert a snippet inside of a snippet, aka

ul[TAB]

产生

<ul>|</ul>

,将光标嵌套在元素之间。

with the cursor nested between the elements.

现在,我想做的就是能够在此代码段内扩展另一个代码段,又称

Now, what I'd want to do is be able to expand another snippet inside of this snippet, aka

ul[TAB]li[TAB]

渲染

<ul><li>|</li></ul>

再次将光标嵌套在元素之间,不幸的是,它成为了崇高文字3中的片段的一部分,[ TAB]将您带到下一个锚点,在这种情况下,退出标签。我发现此功能非常方便,但在这种情况下是PITA。上面列出的击键将呈现:

once again with the cursor nested between the elements, unfortunately as part of snippets in sublime text 3, [TAB] brings you to the next anchor point, in this case, exiting the tag. I find this feature incredibly handy, but in this case, a PITA. The above listed keystrokes would render:

<ul>li</ul>|

,光标位于结束标记之后。

with the cursor after the closing tag.

是否可以退出该代码段,以便随后输入新的代码段?

Is there a way to exit out of the snippet, so that I can then enter a new snippet?

推荐答案

您可以使用 $ 0 来指定光标的位置:

You can specify the position of the cursor using $0, example:

<snippet> <content><![CDATA[ <ul>$0</ul> ]]></content> <tabTrigger>ul</tabTrigger> <scope>text.html</scope> </snippet>

我建议您看一下出色的 Emmet 插件,因为它使嵌套HTML标签的支架非常容易。

I recommend taking a look at the excellent Emmet plugin, as it makes scaffolding of nested HTML tags pretty easy.

更多推荐

在另一个代码片段内部时,如何展开一个代码片段?

本文发布于:2023-11-26 12:27:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1633930.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:片段   代码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!