I do both python and node coding. I have a keybinding for console.log() in Visual Studio Code.
{
"key": "ctrl+shift+l",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "console.log('$0',)"
}
}
I want this same shortcut to detect the .py
extension and print print('',)
and detect .js, .ts
file extension and print console.log('',)
{
"key": "ctrl+shift+l",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && editorLangId == javascript",
"args": {
"snippet": "console.log('$0',)"
}
},
{
"key": "ctrl+shift+l",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && editorLangId == typescript",
"args": {
"snippet": "console.log('$0',)"
}
},
{
"key": "ctrl+shift+l",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && editorLangId == python",
"args": {
"snippet": "print('$0',)"
}
},
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.