TL; DR
{
"key": "ctrl+2",
"command": "runCommands",
"args": {
"commands": [
"editor.action.clipboardCopyAction", // Copy selection
"editor.action.insertLineAfter", // Move to next line (deselects)
{
"command": "editor.action.insertSnippet",
"args": {
// Use clipboard content
"snippet": "console.log('🤖🤖🤖 $CLIPBOARD:', $CLIPBOARD)"
}
}
]
},
"when": "editorHasSelection" // Only run when text is selected
}
If you want to log out a label only, then this goes hand-in-hand with the above
{
"key": "ctrl+1",
"command": "runCommands",
"args": {
"commands": [
"editor.action.clipboardCopyAction", // Copy selection
"editor.action.insertLineAfter", // Move to next line (deselects)
{
"command": "editor.action.insertSnippet",
"args": {
// Use clipboard content
"snippet": "console.log('🙃🙃🙃 $CLIPBOARD')"
}
}
]
},
"when": "editorHasSelection" // Only run when text is selected
},