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

如何为Command Palette中的Select to Bracket绑定Ctrl+M快捷键

How to Bind "Select to Bracket" to Ctrl+M in VS Code

No problem at all—let’s walk through setting up this keyboard binding step by step:

  • Open Keyboard Shortcuts settings
    You’ve got two easy ways to get here:

    1. Use the direct shortcut: Press Ctrl+K then Ctrl+S (Windows/Linux) or Cmd+K then Cmd+S (Mac).
    2. Via Command Palette: Hit Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux), search for Preferences: Open Keyboard Shortcuts, and select it.
  • Locate the "Select to Bracket" command
    In the search bar at the top of the Keyboard Shortcuts page, type "Select to Bracket". You’ll see the matching command editor.action.selectToBracket show up right away.

  • Assign the Ctrl+M shortcut
    Pick whichever method feels more comfortable for you:

    1. Graphical interface: Click the pencil icon next to the command, then press Ctrl+M on your keyboard. If this shortcut is already tied to another feature, VS Code will flag a conflict—you can choose to overwrite the existing binding or tweak things if you want to keep the old shortcut.
    2. Edit the JSON config: Click the curly braces {} icon in the top-right corner of the Keyboard Shortcuts page to open keybindings.json. Add this entry to the array:
      {
          "key": "ctrl+m",
          "command": "editor.action.selectToBracket",
          "when": "editorTextFocus && !editorReadonly"
      }
      
      The when line makes sure the shortcut only activates when you’re focused on an editable text editor (so it won’t fire when you’re in a settings panel or terminal).

Save your changes (if you edited the JSON file) and you’re all set—Ctrl+M will now trigger the Select to Bracket feature instantly!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 08:04:39