Skip to content

Conversation

yanzhe-Xiao
Copy link

新增了支持Vscode里标准的Snippet语法的实现
我们以python里的for循环为例

{
                    "triggerWord": "fori",
                    "description": "For loop with enumerate",
                    "targetRegExp": "[\\w\\.]+",
                    "body": [
                        "for i, item in enumerate(${target}):",
                        "\t${0:pass}",
                        ""
                    ]
                },

新增的效果即可以识别${0:pass}这种语法即${序号:varilable},我们将前面的数字定义为Tabstop,下面列出常见的Tabstop编号
${0:content} - 最终光标位置
这是Tabstop序列的结束位置
当用户按Tab键跳过所有占位符后,光标会停留在这个位置
${1:content} - 第一个可编辑占位符
用户第一次按Tab键会跳转到这里
可以有多个相同编号的占位符,它们会同时编辑
${2:content} - 第二个可编辑占位符
用户第二次按Tab键会跳转到这里

实际编写代码的效果
image
image
如图所示,pass会被选中然后用户输入会自动删掉
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant