Sublime 文本片段:如何将选项定义为值?

问题描述 投票:0回答:1

有没有一种解决方案可以在 Sublime Text 中创建一个片段,其中值可以有多种方法(选择)。例如,在Python中,列表可以有多种方法(append、clear、copy)。 在 Vs 代码中创建和定义选择很容易,如下所示:

   "python list": {
  "prefix": "py_list",
  "body": [
    "${1:mylist}.${2|append,clear|}(\"${3:orange}\")",
    ""
  ],
  "description": "python list"
}

但是在 Sublime Text 中,以下代码显示两者(追加和清除方法),没有选项

  <snippet>
  <content><![CDATA[
${1:mylist}.${2|append,clear|}("${3:orange}")

]]></content>
  <tabTrigger>py_list</tabTrigger>
  <description>python list</description>
  <!-- Optional: Set a scope to limit where the snippet will trigger -->
  <!-- <scope >source.python</scope > -->
</snippet>

提前致谢

sublimetext3 code-snippets
1个回答
0
投票

Sublime Text 本身不支持片段中的选项。在 https://github.com/sublimehq/sublime_text/issues/3607 有一个开放的功能请求。 但这也不全是坏消息 - 有一个包提供了此功能:https://packagecontrol.io/packages/EnhancedSnippets

© www.soinside.com 2019 - 2024. All rights reserved.