繁体   English   中英

使用用户定义的代码段覆盖VS代码代码段

[英]Overwrite VS Code snippet with user defined snippet

我已经在Visual Studio Code中配置了以下TypeScript代码段

"console.log": {
        "prefix": "cl",
        "body": [
            "console.log();"
        ],
        "description": "console.log()"
    }

但是,它不起作用,因为已经为cl (类)定义了一个片段。 如何用我的代码覆盖该代码段? 我想使用cl ,因为我以相同的方式配置了其他IDE,并且不希望更改我的约定。

键入cl ,将显示cl代码段所有可能扩展的列表,您的代码段可能位于列表的底部。 为了访问列表顶部的代码段,您可以将以下内容添加到settings.json

// Place your settings in this file to overwrite the default settings
{
    "typescript.useCodeSnippetsOnMethodSuggest": true,
    "editor.snippetSuggestions": "top",
    "editor.tabCompletion": true
}

在这里注意editor.snippetSuggestions 此设置定义自动完成列表的排序,当您键入代码段的缩写时,该列表将显示。 默认情况下,它是bottom ,这就是您的代码段出现在列表末尾的原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM