Option + backspace does not delete the last word
Open 💬 10 comments Opened Sep 27, 2025 by markusylisiurunen
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
What version of Codex is running?
codex-cli 0.42.0
Which model were you using?
Any model (e.g. gpt-5-codex)
What platform is your computer?
Darwin 24.6.0 arm64 arm
What steps can reproduce the bug?
- Open
codexand write a few words into the prompt. - Move the cursor to a word boundary and press
option+backspace.
What is the expected behavior?
The last word should be deleted, ending at the cursor position.
What do you see instead?
Only a single character gets deleted, as if option is not pressed at all.
Additional information
I am using Ghostty as my terminal, but the same bug happens in the macOS' own Terminal app as well.
10 Comments
Most of the other common text editing shortcuts work as expected:
option+left/right arrowmoves the cursor one word at a time.cmd+left/right arrowmoves the cursor to the beginning or end of line.cmd+backspacedeletes the entire line.There actually seems to be a test case in place for this exact key combination:
https://github.com/openai/codex/blob/5c67dc3af12ab5426ba5002a90a50b24f1dcf8f9/codex-rs/tui/src/bottom_pane/textarea.rs#L1246
Codex works as expected when I explicitly set Ghostty keybinding to this:
Perhaps the issue is that the
ALTmodifier is not somehow either passed or parsed correctly.thanks a lot for the solution 'Codex works as expected when I explicitly set Ghostty keybinding to this:
keybind = alt+backspace=text:\x1b\x7f' ; both codex and qwen are working as expected now
So have you also found a solution to selecting. When using cmd+a it selects the whole chat. cmd+shift+arrow doesn't seem to work even when setting it in terminal/cursor shortcuts. Does this work differently for you?
Ok,I debugged into this, and here's what I found.
on macos:
| Key Combination | Actual Behaviour | Expected Behaviour |
| ------------------------- | ---------------- | ---------------------------------- |
| right option + backspace | delete line | delete line |
| right command + backspace | delete word | delete word |
| left command + backspace | delete line | delete line |
| left option + backspace | delete char | delete word |
| left control + backspace | delete char | no special behaviour (delete char) |
Here's a patch that fixes ths issue (codex's contributing.md doesn't allow external PRs without permission)
<details>
<summary>patch.diff</summary>
</details>
This paatch aligns the behaviour with browsers/other CLI worlkflows.
EDIT: somehow after fixing and testing the patch, it's working now in some of my codex instances - but not others 🤷
@camc314, thanks for the analysis. Have you done any testing with other terminal emulator apps? We need to ensure broad compatibility across many terminals on all supported platforms, which is what makes issues like this difficult.
I've tried https://ghostty.org and VSCode, and both appear to have the same behaviour.
Apple's terminal doesn't appear to send the key modifiers to the TUI (in here, the modifiers are always empty)
Here are some other references that might be helpful:
This is a limitation of how Terminal.app handles this key combination.
In Terminal.app:
<img width="779" height="740" alt="Image" src="https://github.com/user-attachments/assets/996cab41-4ad2-4370-bf00-72190886dded" />
This makes Option+Backspace send ESC + Backspace (\x1b\x7f) instead of just Backspace (\x7f). Most shells interpret that as "delete word backward."
If you only want to remap that specific combo (without making Option a full Meta key), you can add a custom mapping in the same Keyboard tab:
<img width="779" height="740" alt="Image" src="https://github.com/user-attachments/assets/1a2ee870-f18c-458d-a0c1-afe8e060ffd4" />
<img width="779" height="740" alt="Image" src="https://github.com/user-attachments/assets/a69b307c-14cb-4b86-9492-9dd13c045e23" />
<img width="294" height="145" alt="Image" src="https://github.com/user-attachments/assets/9bdf1b0c-03c9-4d05-b996-21fd9e77b5b4" />
<img width="779" height="740" alt="Image" src="https://github.com/user-attachments/assets/5fd82968-68e4-4507-a25c-9928927f26f2" />
The "Use Option as Meta key" approach is simpler but changes the behavior of all Option+key combos. The custom mapping approach is surgical — it only affects Option+Backspace.
I can confirm that:
1) the same issue exists with
kittyterminal on linux using ctrl+backspace (backward delete word) and ctrl+shift+backspace (forward delete word)2) neither claude code nor gemini CLI have this issue, both shortcuts work. It's a codex problem, not a terminal or OS problem.
I confirm it's happening on Ghostty