VS Code Shortcuts on macOS with Russian Keyboard Layout: Fix for Cmd+, and More
On macOS, the Cmd+, shortcut opens Settings in virtually every native app—Safari, Finder, Chrome. In VS Code, however, it fails when the Russian keyboard layout is active. The root cause? VS Code processes shortcuts by character, not physical key position. With the Russian layout, the comma key outputs "B"—so VS Code looks for Cmd+B and finds no matching command.
Electron-based apps—including VS Code—bind shortcuts to characters, unlike native macOS apps, which bind to scan codes (physical key positions).
Diagnosing the Issue: From Hypothesis to Root Cause
Troubleshooting steps—including checking focus, testing other shortcuts (Cmd+Shift+P works fine), ruling out system conflicts, extensions, or background processes—revealed no issues. The critical diagnostic step is VS Code’s Record Keys mode in Keyboard Shortcuts: it correctly registers "cmd+[Comma]", yet no command is triggered.
Switching to the English layout confirms the issue: the problem lies in how non-alphabetic keys are mapped across different keyboard layouts.
Fix via keybindings.json
Create or edit ~/Library/Application Support/Code/User/keybindings.json and add a binding using the physical key name:
[
{ "key": "cmd+[Comma]", "command": "workbench.action.openSettings" }
]
Square brackets around [Comma] tell VS Code to bind to the physical key, not its character output. This fix works reliably across all keyboard layouts.
Complete Set of Fixes for Non-Alphabetic Shortcuts
This issue affects all Cmd+symbol shortcuts on non-Latin layouts. Here’s a recommended keybindings.json configuration:
[
{ "key": "cmd+[Comma]", "command": "workbench.action.openSettings" },
{ "key": "cmd+[Period]", "command": "editor.action.quickFix", "when": "editorHasCodeActionsProvider && editorTextFocus" },
{ "key": "cmd+[Slash]", "command": "editor.action.commentLine", "when": "editorTextFocus" },
{ "key": "cmd+[BracketLeft]", "command": "editor.action.outdentLines", "when": "editorTextFocus" },
{ "key": "cmd+[BracketRight]", "command": "editor.action.indentLines", "when": "editorTextFocus" },
{ "key": "cmd+[Backslash]", "command": "workbench.action.splitEditor" }
]
- Cmd+. — Trigger Quick Fix
- Cmd+/ — Toggle line comment
- Cmd+[+] — Indent selected lines (via
[BracketRight]) - Cmd+\ — Split editor
Bonus: Open Terminal Links in Your Default Browser
Set remote.forwardedPorts.openBrowserKind to force VS Code to open forwarded ports—including local development servers—in your default external browser instead of the built-in Simple Browser.
In settings.json:
"remote.forwardedPorts.openBrowserKind": "external"
Key Takeaways
- VS Code binds shortcuts by character; macOS binds by scan code (physical key)
- Using
cmd+[Comma]inkeybindings.jsonresolves the issue universally—no layout switching required - This affects all Electron apps and any non-alphabetic key (e.g.,
/,.,[,],\,,) - Keyboard Shortcuts’ Record Keys mode displays the actual scan code—use it to verify bindings
- The port-forwarding setting works for local dev servers too—even though it’s named
remote.*
— Editorial Team
No comments yet.