在 vscode 中检测文件扩展名

detect file extension in vscode

我同时进行 python 和节点编码。我在 Visual Studio 代码中有 console.log() 的键绑定。

  {
    "key": "ctrl+shift+l",
    "command": "editor.action.insertSnippet",
    "when": "editorTextFocus",
    "args": {
        "snippet": "console.log('[=11=]',)"
    }
  }

我想要这个相同的快捷方式来检测 .py 扩展名并打印 print('',) 并检测 .js, .ts 文件扩展名并打印 console.log('',)

{
    "key": "ctrl+shift+l",
    "command": "editor.action.insertSnippet",
    "when": "editorTextFocus && editorLangId == javascript",
    "args": {
        "snippet": "console.log('[=10=]',)"
    }
},
{
    "key": "ctrl+shift+l",
    "command": "editor.action.insertSnippet",
    "when": "editorTextFocus && editorLangId == typescript",
    "args": {
        "snippet": "console.log('[=10=]',)"
    }
},
{
    "key": "ctrl+shift+l",
    "command": "editor.action.insertSnippet",
    "when": "editorTextFocus && editorLangId == python",
    "args": {
        "snippet": "print('[=10=]',)"
    }
},