摘要中的Tab功能的ST3交换优先级(嵌套摘要) [英] ST3 swap priority of tab function within a snippet (nested snippets)

查看:84
本文介绍了摘要中的Tab功能的ST3交换优先级(嵌套摘要)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发现自己经常调用一个代码段中的一个代码段,但是,当我去扩展嵌套代码段时,Tab键会将我移到第一个代码段的下一个条目或第一个代码段的末尾(此时,我必须将光标替换为第二个代码段的tab-trigger表达式的末尾,然后点击tab,这时第二个代码段将展开。

Find myself frequently invoking a snippet within a snippet, but of course when I go to expend the nested snippet, the tab key moves me to either the next entry of the first snippet or the end of the first snippet (at which point, I have to replace the cursor at the end of the tab-trigger expression for the 2nd snippet and hit tab, at which point the 2nd snippet is expanded).

例如。给定的片段 [内容A $ {1:A中的第一点和$ {2:A}中的第二点] ,并使用制表键触发 tabtrigA 和摘要 [内容B] ,并使用Tab键触发 tabtrigB

eg. given snippet [ content A ${1:First point in A} and ${2: Second point in A} ] with tab-trigger tabtrigA and snippet [ content B ] with tab-trigger tabtrigB

我希望能够执行以下操作:

I'd like to be able to do the following:

In [1]:

tabtrigA % Hit tab to expand snippet A

Out [1]:

 [ content **A First point in A** and ${2: Second point in A} ] % where everything between ** ** is highlighted

现在替换 * * ... ** 包含 tabtrigB

In [2]:

     [ content tabtrigB* and ${2: Second point in A} ] % where * marks location of cursor.

并点击 tab 会导致:

Out [2]:

 [ content [ content B ]* and ${2: Second point in A} ] % where * marks location of cursor

的位置,然后点击 tab 会再次跳到摘要A的第二个条目

and hitting tab again would then jump to second entry of snippet A

显然这很烦人:是否有可能切换 tab 的优先级分配,使其首先充当Tab触发,并且仅在没有Tab触发的情况下才跳转到下一个条目?

Obviously this is tiresome: is it possible to switch the priority assignment of tab so that it first acts as a tab-trigger and only jumps to next entry if there is no tab-trigger?

更新:截至2019年4月,仍然没有解决方案来触发摘要中的摘要。

Update: as of April 2019, still no solution for triggering a snippet within a snippet.

推荐答案

我认为Sublime不能从告诉 this 片段的next_field 片段的next_field。您只能询问它是否具有has_next_field。但是您可以采用以下解决方法:

I don't think sublime can tell this snippets' next_field from that snippet's next_field. You can only ask if it has_next_field, any. But you could go with workarounds:


  1. 通过命令面板,为嵌套的片段提供描述。下面的代码段可以从面板中作为代码段调用:description_for_command_palette

  1. Through command palette by giving your nested snippet a description. The snippet below will be callable from the palette as Snippet: description_for_command_palette.


<snippet>
<content><![CDATA[
[ content B ]
]]></content>
<description>description_for_command_palette</description>
</snippet>




  1. 通过键盘绑定到代码段路径:

{ keys:[ ctrl + 0], command: insert_snippet, args :{名称:软件包/用户/您的snippet.sublime-snippet}}


  1. 通过与匿名代码段的快捷键绑定:

{ keys:[ ctrl + 0], command: insert_snippet, args:{ contents: [content B]}}

只需添加两个键绑定:

{ "keys": ["enter"], "command": "next_field", "context":
[
{ "key": "has_next_field", "operator": "equal", "operand": true }
]
},
{ "keys": ["tab"], "command": "insert_best_completion", "args": {"default": "\t", "exact": false}, "context":
[
{ "key": "has_next_field", "operator": "equal", "operand": true }
]
}

这篇关于摘要中的Tab功能的ST3交换优先级(嵌套摘要)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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