Over-ride Default Snippet Prefix in VS Code

ぐ巨炮叔叔 提交于 2019-12-12 09:27:30

问题


I am writing some JavaScript snippets for VS Code, and when I add the one for an event listener, there are a number of pre-defined prefix allocations relating to other pieces of code. I would like to use "ael" as the prefix prompt for this snippet, but that defaults to an alert command (this is particularly frustrating because the first 3 letters of alert are actually "ale"), anyway, is there a way of over-riding the default behaviour?

In the code below if I change the prefix to "ttt", and subsequently type "ttt", the snippet works, when I use "ael" it doesn't.

How do I over-ride this?

SNIPPET

"ael": {
    "prefix": "ael",
    "body": [
        "addEventListener(\"\t$1\", function(){",
        "\t$2",
        "}, false);"
    ],
    "description": "Add an Event Listener",
}


回答1:


It's a part of the latest update: 1.19 release notes

When you accept a suggestion it remembers and jumps to the thing that you previously accepted. Here is the issue about controlling this feature: #41060

Since vscode 1.20 there is an option to disable or modify this behavior:

"editor.suggestSelection"

"first" - as it was before (no rememering, no preselecting)

"recentlyUsed" - select the previously used item

"recentlyUsedByPrefix" - select items based on prefixes you have used



来源:https://stackoverflow.com/questions/48304160/over-ride-default-snippet-prefix-in-vs-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!