Sublime text snippet : how to define choices as value?

12 views Asked by At

is there a solution to create a snippet in sublime text where the value can have several methods (choices) . For example , in Python a list can have multiple methods (append , clear , copy) . It's easy to create and define choice in Vs code like that :

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

but in sublime text the following code display both (append and clear methods ) without option

  <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>

thanks in advance

1

There are 1 answers

0
Keith Hall On

Natively, Sublime Text doesn't support options in snippets. There is an open feature request for it at https://github.com/sublimehq/sublime_text/issues/3607. But it's not all bad news - there is a package which provides this functionality: https://packagecontrol.io/packages/EnhancedSnippets