You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VSCode中实现复制(Cmd+C)操作的弹窗通知或提示音?

在VSCode中实现复制时触发弹窗/提示音

方法一:用自定义快捷键结合内置命令实现弹窗

  1. 打开快捷键配置文件:按下Cmd+Shift+P(Mac),输入Preferences: Open Keyboard Shortcuts (JSON),打开keybindings.json。
  2. 添加以下配置,替换默认复制快捷键的同时触发信息弹窗:
[
    {
        "key": "cmd+c",
        "command": "runCommands",
        "args": {
            "commands": [
                "editor.action.clipboardCopyAction",
                "notifications.showInformationMessage"
            ]
        },
        "when": "editorTextFocus && !editorReadonly"
    }
]
  • 说明:runCommands会批量执行命令,先完成默认复制动作,再弹出系统信息通知。

方法二:结合扩展实现自定义弹窗或提示音

如果需要自定义弹窗内容或添加提示音,可通过扩展实现:

实现提示音

  1. 安装Notification Sound扩展。
  2. 修改keybindings.json,绑定复制快捷键同时播放提示音:
[
    {
        "key": "cmd+c",
        "command": "runCommands",
        "args": {
            "commands": [
                "editor.action.clipboardCopyAction",
                "notification-sound.play"
            ]
        },
        "when": "editorTextFocus && !editorReadonly"
    }
]
  • 可在扩展设置页调整提示音文件、音量等参数。

实现自定义文本弹窗

  1. 安装Command Runner扩展。
  2. 打开settings.json,添加自定义命令:
"command-runner.commands": {
    "copy-with-custom-notify": [
        "editor.action.clipboardCopyAction",
        "notifications.showInformationMessage",
        "内容已复制!"
    ]
}
  1. 在keybindings.json中绑定快捷键:
{
    "key": "cmd+c",
    "command": "command-runner.run",
    "args": { "command": "copy-with-custom-notify" },
    "when": "editorTextFocus && !editorReadonly"
}

注意事项

  • 若要保留终端内的默认复制行为,可在when条件中添加&& !terminalFocus,区分编辑器和终端场景。

内容的提问来源于stack exchange,提问作者Mehdi Faraji

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 08:52:03