Visual studio code VSC-是否可以从多个文件中读取代码片段?

Visual studio code VSC-是否可以从多个文件中读取代码片段?,visual-studio-code,Visual Studio Code,如果有一个名为javascript.json-->的文件,那么在使用VSC时,每个.js文件都会读取其内容 在vsc中编辑js文件时,我不仅希望阅读javascript.json中的代码片段,还希望阅读javascript2.json中的代码片段。(或任何其他随机名称,主要是从多个json文件中读取javascript代码片段) 有办法做到这一点吗?您可以在您的工作区.vscode目录中有其他代码段文件 文件的扩展名为:。代码片段 您可以使用scope属性来限制代码段的语言 { /

如果有一个名为javascript.json-->的文件,那么在使用VSC时,每个.js文件都会读取其内容

  • 在vsc中编辑js文件时,我不仅希望阅读javascript.json中的代码片段,还希望阅读javascript2.json中的代码片段。(或任何其他随机名称,主要是从多个json文件中读取javascript代码片段)


  • 有办法做到这一点吗?

    您可以在您的工作区
    .vscode
    目录中有其他代码段文件

    文件的扩展名为:
    。代码片段

    您可以使用
    scope
    属性来限制代码段的语言

    {
        // Place your test workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 
        // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 
        // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is 
        // used to trigger the snippet and the body will be expanded and inserted. Possible variables are: 
        // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. 
        // Placeholders with the same ids are connected.
      "Print to console": {
        "scope": "javascript,typescript",
        "prefix": "log",
        "body": [
          "console.log('$1');",
          "$2"
        ],
        "description": "Log output to console"
      }
    }