第一步
输入这些
javascript
{
// Print Selected Variabl 为自定义快捷键中需要使用的name,可以自行修改
"Print Selected Variable": {
"body": [
"\nconsole.log(",
" '%c $CLIPBOARD: ',",
" 'background-color: #3756d4; padding: 4px 8px; border-radius: 2px; font-size: 14px; color: #fff; font-weight: 700;',",
" $CLIPBOARD$1",
")"
],
"description": "Print Selected Variable"
}
}
第二步 设置快捷键
javascript
{
"key": "z", // 自定义快捷键
"command": "runCommands", // 运行多个命令
"args": {
"commands": [
{
"command": "editor.action.clipboardCopyAction" // 复制选中文本
},
{
"command": "cursorEnd" // 光标移到最后
},
{
"command": "editor.action.insertSnippet", // 插入片段
"args": {
"name": "Print Selected Variable" // 调用已配置的代码片段,这里是代码片段里定义的值
}
}
]
}
}