Cursor Basics
Cursor keybindings.json: When Clauses, Chords and Recipes
Cursor uses VS Code's keybindings.json format: run Preferences: Open Keyboard Shortcuts (JSON) from the command palette to open the file. Each entry pairs a key with a command and an optional when clause that scopes it by context. The main Cursor difference is the chord leader, which is ⌘R on Mac because Cursor uses ⌘K for its AI side panel.

On this page
Where is keybindings.json in Cursor?
Cursor is a VS Code fork, so the whole keybinding system carries over: a Keyboard Shortcuts screen for point-and-click remapping, and a keybindings.json file for anything precise. Open either one from the command palette (⌘Ctrl⇧P):
- 1Run Preferences: Open Keyboard Shortcuts for the searchable screen. Every Cursor binding, including the AI features, can be remapped there.
- 2Run Preferences: Open Keyboard Shortcuts (JSON) to edit
keybindings.jsondirectly. Entries in this file win over the defaults. - 3Right-click any row on the screen and choose Copy Command ID when you need the exact command name for a JSON entry.
[
{
"key": "ctrl+alt+r",
"command": "workbench.action.reloadWindow",
"when": "editorTextFocus"
}
]Use those three in that order, even when you already know the command you want.
Copy Command ID gives you the exact string without typing it from memory, and searching the screen by key shows everything already bound to that key, with each binding's when clause. You can't see either of those from inside the file.
Where the file lives also decides how a team shares bindings. keybindings.json is a per-user file in Cursor's own user-data directory, so it carries every private remap its owner ever made. Don't send a colleague the whole file. Share the three or four entries that matter, with their command IDs, wherever your team already reads things, and remember that Mac chord keys are not the keys a Windows colleague presses.
Cursor's shortcut doc confirms the scope: "All Cursor keybindings, including Cursor-specific features, can be remapped in Keyboard Shortcuts settings." It doesn't document the when system that decides when a binding is live. That part comes from the VS Code layer underneath, and it is where most broken bindings go wrong.
This is covered hands-on in Cursor First Hour — 4 short Units, free to read.
Rather do it than read about it? Run 11 interactive Cursor walkthroughs in a simulated editor. Free, no account needed.
How do when clauses work?
A when clause is a boolean expression over context keys: live flags the editor keeps about focus, selection, mode and UI state. A binding with no when is global. With one, the shortcut fires only while the expression is true, which is how the same key can mean different things in the editor, the terminal and a chat input.
- Operator
- &&
- Meaning
- and
- Example
- editorTextFocus && editorHasSelection
- Operator
- ||
- Meaning
- or (lowest precedence)
- Example
- terminalFocus || panelFocus
- Operator
- !
- Meaning
- not
- Example
- editorTextFocus && !editorReadonly
- Operator
- == / !=
- Meaning
- equality against a value
- Example
- editorLangId == 'typescript'
- Operator
- =~
- Meaning
- regex match
- Example
- resourceFilename =~ /\.test\.ts$/
- Operator
- in / not in
- Meaning
- membership in a list-valued key
- Example
- resourceFilename in supportedFiles
| Operator | Meaning | Example |
|---|---|---|
| && | and | editorTextFocus && editorHasSelection |
| || | or (lowest precedence) | terminalFocus || panelFocus |
| ! | not | editorTextFocus && !editorReadonly |
| == / != | equality against a value | editorLangId == 'typescript' |
| =~ | regex match | resourceFilename =~ /\.test\.ts$/ |
| in / not in | membership in a list-valued key | resourceFilename in supportedFiles |
Operator set from the VS Code when-clause reference; precedence is ! over && over ||.
Watch the precedence. Because || binds loosest, editorTextFocus && editorLangId == 'typescript' || terminalFocus parses as (editor and TypeScript) or terminal, so the binding fires in the terminal too. Split an expression like that into two entries with the same key and command and one condition each. The file gets longer, but each entry is easier to read six months later.
- editorTextFocus
- The cursor is in editor text. This is the default guard for editing commands.
- editorHasSelection
- Some text is selected. Pair it with commands that act on a selection.
- textInputFocus / inputFocus
- Any text input has focus, including chat and search boxes. Use ! to keep editor keys out of inputs.
- terminalFocus
- The integrated terminal owns the keyboard.
- isInDiffEditor
- The active editor is a diff view, useful for review-time bindings.
- sideBarFocus / panelFocus
- The side bar or bottom panel has focus.
- inDebugMode
- A debug session is running.
- editorLangId
- The language of the active file, compared with == (e.g. 'markdown').
Inherited VS Code keys that behave identically in Cursor.
A binding that works in the editor but also fires inside the chat input, or the reverse, is almost always missing a focus guard. Scope editor commands with editorTextFocus, and keep global commands away from typing surfaces with !textInputFocus.
Guarding too tightly fails the other way, and it is harder to notice, because the binding does work, but not everywhere you expected. A key scoped to editorTextFocus goes quiet as soon as focus moves to the file tree or a chat box.
How do I find Cursor-specific context keys?
Cursor doesn't publish a list of its own context keys, so inspect them live in your build, which also protects you from renames between releases. Two built-in developer tools do it, and the Keyboard Shortcuts screen helps too:
- 1Run Developer: Inspect Context Keys from the command palette, then click any part of the UI (the chat pane, the editor, a diff). The developer console prints every context key and its current value for that spot, and Cursor's AI-surface keys show up alongside the VS Code ones.
- 2Run Developer: Toggle Keyboard Shortcuts Troubleshooting, then press the shortcut that isn't behaving. The log shows each keystroke, every rule it matched and which binding won, which is the fastest way to find what is shadowing your key.
- 3On the Keyboard Shortcuts screen, search for the key you care about (for example, type "cmd+k") to see every command competing for it and each one's when clause.
Open the troubleshooting log when a key does nothing at all. A rule that never matched and a rule that matched and then lost the key feel identical from the keyboard, and the log tells them apart. Read it before you edit the entry.
Cursor ships fast, and internal command IDs and context keys can change between versions. The inspect and troubleshooting tools read your running build, so their answer is always current. Treat any hardcoded list of Cursor-internal keys, including one from this page's sources, as a starting point to verify.
Why did my Cmd+K chords stop working in Cursor?
In VS Code, ⌘CtrlK is the chord leader, the first key of two-step shortcuts like ⌘K ⌘S (open shortcuts) or ⌘K ⌘W (close all). Cursor took ⌘K for its AI features, so it moved the chord leader to ⌘R on Mac. A Cursor staff answer on the forum, written when the key opened inline edit, explains the change: "⌘CtrlK is used for the inline edits. We therefore changed the keychord leader key to be ⌘R on Mac and CtrlM on Windows and Linux."
- You knew it as (VS Code)
- ⌘K ⌘S
- In Cursor it is
- ⌘R ⌘S
- What it does
- Open Keyboard Shortcuts
- You knew it as (VS Code)
- ⌘K ⌘W
- In Cursor it is
- ⌘R ⌘W
- What it does
- Close all editors
- You knew it as (VS Code)
- ⌘K Z
- In Cursor it is
- ⌘R Z
- What it does
- Zen mode
- You knew it as (VS Code)
- ⌘K (alone)
- In Cursor it is
- ⌘K
- What it does
- AI side panel, or Agent with your selection
| You knew it as (VS Code) | In Cursor it is | What it does |
|---|---|---|
| ⌘K ⌘S | ⌘R ⌘S | Open Keyboard Shortcuts |
| ⌘K ⌘W | ⌘R ⌘W | Close all editors |
| ⌘K Z | ⌘R Z | Zen mode |
| ⌘K (alone) | ⌘K | AI side panel, or Agent with your selection |
Mac keys shown. For Windows and Linux, the staff answer gives Ctrl+M as the leader, but it opens Keyboard Shortcuts with Ctrl+R then Ctrl+S, as Cursor's help page does. Check the other chords on your build.
Imported VS Code keybindings can also break for a second reason. Users on the Cursor forum found imported entries whose when fields read (arbitrary function), a placeholder left when a condition couldn't be carried across. Those bindings never fire. Delete them and rebind through Cursor's Keyboard Shortcuts screen instead of pasting your old file wholesale.
The leader itself is configurable. On the Keyboard Shortcuts screen, search for the keychord leader and set it back to ⌘K. You then share the key with Cursor's AI side panel, so scope one of them with a when clause.
Whether to move the leader back depends on how much of your muscle memory sits on two-step chords, and the swap has a cost that isn't obvious. The first row of the table is the one that bites: ⌘R ⌘S opens the Keyboard Shortcuts screen, so moving the leader also moves the way into the screen you use when a binding misbehaves. The command palette still gets you there either way.
What are useful keybindings.json recipes for Cursor?
Three patterns cover nearly everything: add a binding with a guard, remove a default you keep hitting by accident, and resolve a conflict by narrowing scope. Removal uses the VS Code convention of prefixing the command with a minus sign.
{
"key": "ctrl+alt+/",
"command": "editor.action.commentLine",
"when": "editorTextFocus && editorLangId == 'typescript'"
}{
"key": "cmd+e",
"command": "-workbench.action.quickOpen"
}{
"key": "cmd+k",
"command": "workbench.action.terminal.clear",
"when": "terminalFocus"
}For Cursor's AI surfaces, get the real command ID first, with Copy Command ID on the Keyboard Shortcuts screen or from the troubleshooting log, then apply the same three patterns. Defaults worth knowing before you remap: ⌘I, ⌘L and ⌘K toggle the side panel, ⌘E toggles the agent layout, ⌘. opens the mode menu, ⌘/ loops between models, and ⇧⌘S opens a side chat from your selection in the chat.
Frequently asked questions
Where is keybindings.json stored in Cursor?
Open it from the command palette with Preferences: Open Keyboard Shortcuts (JSON). Cursor uses the same per-user file mechanism as VS Code, in Cursor's own user-data directory. Always open it through that command, so you edit the file your running build reads.
Why don't my VS Code keybindings work after importing into Cursor?
Two causes dominate. Cursor moved the chord leader off ⌘CtrlK, because it uses ⌘K for its AI side panel, so all your two-step ⌘K chords changed. The leader is ⌘R on Mac, and a Cursor staff answer gives CtrlM for Windows and Linux. Some imported entries also arrive with a broken when field reading '(arbitrary function)'. Those never fire and need to be deleted and rebound.
What is a when clause in a keybinding?
A boolean expression over live context keys (focus, selection, language, mode) that gates the binding. No when clause means the shortcut is global. With one, it only fires while the expression is true, for example editorTextFocus && !editorReadonly.
Why does my when clause fire somewhere I did not intend?
Usually precedence. || binds loosest, so editorTextFocus && editorLangId == 'typescript' || terminalFocus means (editor and TypeScript) or terminal, and the binding fires in the terminal as well. Where an expression could be read that way, write two entries with the same key and command and one condition each.
How do I see which context keys are active in Cursor?
Run Developer: Inspect Context Keys from the command palette and click the part of the UI you care about. Every key and value prints to the developer console. For misbehaving shortcuts, Developer: Toggle Keyboard Shortcuts Troubleshooting logs each keypress and which binding won.
Can I rebind Cursor's AI shortcuts, like the agent panel?
Yes. Cursor's documentation states that all keybindings, including Cursor-specific features, can be remapped in Keyboard Shortcuts settings. Use Copy Command ID on the Keyboard Shortcuts screen to get the exact command name, then bind it in keybindings.json, with a when guard if the key is shared.
Sources & last verified
- Cursor Docs - Keyboard Shortcuts
- VS Code Docs - Key Bindings
- VS Code Docs - When Clause Contexts
- Cursor Forum - Imported keybindings with '(arbitrary function)' when clauses
- Cursor Forum - How do I change the keyboard shortcuts Cursor uses?
- Cursor Help: Keyboard shortcuts
- Cursor Help: Agent mode
- Cursor Forum: How do I change the keychord bindings? (staff answer)
Cursor ships frequently. Last updated October 28, 2026.