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?

  1. Open codex and write a few words into the prompt.
  2. 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.

View original on GitHub ↗

10 Comments

markusylisiurunen · 9 months ago

Most of the other common text editing shortcuts work as expected:

  • option + left/right arrow moves the cursor one word at a time.
  • cmd + left/right arrow moves the cursor to the beginning or end of line.
  • cmd + backspace deletes the entire line.
markusylisiurunen · 9 months ago

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:

keybind = alt+backspace=text:\x1b\x7f

Perhaps the issue is that the ALT modifier is not somehow either passed or parsed correctly.

Schreezer · 9 months ago

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

Cornelivl · 7 months ago

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?

camc314 · 5 months ago

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>

git diff --staged
diff --git a/codex-rs/tui/src/bottom_pane/textarea.rs b/codex-rs/tui/src/bottom_pane/textarea.rs
index 0235f7a9c..d3d0a5112 100644
--- a/codex-rs/tui/src/bottom_pane/textarea.rs
+++ b/codex-rs/tui/src/bottom_pane/textarea.rs
@@ -294,6 +294,11 @@ impl TextArea {
                 code: KeyCode::Backspace,
                 modifiers: KeyModifiers::ALT,
                 ..
+            }
+            | KeyEvent {
+                code: KeyCode::Backspace,
+                modifiers: KeyModifiers::CONTROL,
+                ..
             } => self.delete_backward_word(),
             KeyEvent {
                 code: KeyCode::Backspace,

</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 🤷

etraut-openai contributor · 5 months ago

@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.

camc314 · 5 months ago
Have you done any testing with other terminal emulator apps?

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:

fcoury contributor · 5 months ago

This is a limitation of how Terminal.app handles this key combination.

In Terminal.app:

  1. Open Terminal → Settings (or Preferences)
  2. Go to Profiles → Keyboard
  3. Check "Use Option as Meta key"

<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:

  1. Click the + button

<img width="779" height="740" alt="Image" src="https://github.com/user-attachments/assets/1a2ee870-f18c-458d-a0c1-afe8e060ffd4" />

  1. Set the key to Delete with the Option modifier
  2. Set the action to "Send text:"

<img width="779" height="740" alt="Image" src="https://github.com/user-attachments/assets/a69b307c-14cb-4b86-9492-9dd13c045e23" />

  1. Click the empty field

<img width="294" height="145" alt="Image" src="https://github.com/user-attachments/assets/9bdf1b0c-03c9-4d05-b996-21fd9e77b5b4" />

  1. Type Esc first, it will add "\033" to the field
  2. Then type Delete (or Backspace on non-Apple/external keyboards), it will add "\177" to the field

<img width="779" height="740" alt="Image" src="https://github.com/user-attachments/assets/5fd82968-68e4-4507-a25c-9928927f26f2" />

  1. Click OK

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.

jgarvin · 3 months ago

I can confirm that:
1) the same issue exists with kitty terminal 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.

costular · 3 months ago

I confirm it's happening on Ghostty