VS Code中的替代默认代码段前缀 [英] Over-ride Default Snippet Prefix in VS Code
问题描述
我正在为VS Code写一些JavaScript代码段,当我为事件监听器添加代码段时,有许多与其他代码段相关的预定义前缀分配.我想使用"ael"作为该代码段的前缀提示,但这默认为警报命令(这特别令人沮丧,因为警报的前三个字母实际上是"ale"),无论如何,有一种解决方法-设置默认行为?
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?
在下面的代码中,如果我将prefix
更改为"ttt",然后键入"ttt",则该代码段有效,而当我使用"ael"时则无效.
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.
我该如何超越呢?
SNIPPET
"ael": {
"prefix": "ael",
"body": [
"addEventListener(\"\t$1\", function(){",
"\t$2",
"}, false);"
],
"description": "Add an Event Listener",
}
推荐答案
这是最新更新的一部分: 1.19发行说明
It's a part of the latest update: 1.19 release notes
当您接受建议时,它会记住并跳至您先前接受的内容.这是有关控制此功能的问题:#41060
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
自vscode 1.20 起,就有一个选项可以禁用或修改此行为:
Since vscode 1.20 there is an option to disable or modify this behavior:
"editor.suggestSelection"
"first"
-像以前一样(没有补救措施,没有预先选择)
"first"
- as it was before (no rememering, no preselecting)
"recentlyUsed"
-选择以前使用的项目
"recentlyUsed"
- select the previously used item
"recentlyUsedByPrefix"
-根据您使用的前缀选择项目
"recentlyUsedByPrefix"
- select items based on prefixes you have used
这篇关于VS Code中的替代默认代码段前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!