如何为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:- Use the direct shortcut: Press
Ctrl+KthenCtrl+S(Windows/Linux) orCmd+KthenCmd+S(Mac). - Via Command Palette: Hit
Cmd+Shift+P(Mac) orCtrl+Shift+P(Windows/Linux), search for Preferences: Open Keyboard Shortcuts, and select it.
- Use the direct shortcut: Press
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 commandeditor.action.selectToBracketshow up right away.Assign the Ctrl+M shortcut
Pick whichever method feels more comfortable for you:- Graphical interface: Click the pencil icon next to the command, then press
Ctrl+Mon 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. - Edit the JSON config: Click the curly braces
{}icon in the top-right corner of the Keyboard Shortcuts page to openkeybindings.json. Add this entry to the array:
The{ "key": "ctrl+m", "command": "editor.action.selectToBracket", "when": "editorTextFocus && !editorReadonly" }whenline 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).
- Graphical interface: Click the pencil icon next to the command, then press
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
相关产品推荐
相关产品推荐

