vscode 快速打印console.log

第一步

输入这些

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" // 调用已配置的代码片段,这里是代码片段里定义的值
                }
            }
        ]
    }
}
相关推荐
Leon Cheng18 小时前
Vue3 + Monaco Editor 实现智能变量编辑器:隐藏花括号的魔法
编辑器
你知道“铁甲小宝”吗丶18 小时前
VSCode使用Claude Code
vscode·ai·ai编程
浪潮IT馆19 小时前
在 VSCode 中调试 JavaScript 的 Jest 测试用例
javascript·ide·vscode
椰汁菠萝20 小时前
VSCode中properties文件读写
ide·vscode·properties
weixin_5500831521 小时前
QTdesigner配置在pycharm里使用anaconda环境配置安装成功
ide·python·pycharm
dvlinker21 小时前
C/C++编程开发工具及实用软件推荐
ide·vscode·visual studio·qt creator·c/c++·source insight·编程工具
Kazefuku1 天前
VS Code 和Visual Studio:简单易懂的区别
ide·windows·visual studio
gsgbgxp1 天前
通过tailscale配置ssh远程实现wsl系统VSCode编程
vscode·深度学习·ubuntu·ssh
Boxsc_midnight1 天前
【一款支持Ollama本地部署的Visual Studio 2022 编程助手插件的编译和生成之路】解决打包安装问题
ide·visual studio·vs插件
-凌凌漆-1 天前
vscode运行npm报错,npm : 无法加载文件 xxxxx/npm.ps1,因为在此系统上禁止运行脚本。
ide·vscode·npm