How to Clear the Input in Codex CLI

Press Ctrl + U to clear what you have typed in Codex CLI. It deletes from the cursor back to the start of the line, so if your cursor is already at the end — which it usually is — that clears the whole thing.

The key people reach for first is Ctrl + L, and it does something else entirely: it clears the terminal display. Your typed text survives. That is why this feels broken the first time — the screen wipes, the prompt looks fresh, and your half-written message is still sitting there.

The three keys that all look like "clear"

KeyWhat it actually clears
Ctrl + UInput text, from the cursor back to the start of the line
Ctrl + KInput text, from the cursor forward to the end of the line
Ctrl + LThe terminal display. Leaves your typed input alone

Ctrl + U and Ctrl + K are a pair — back and forward from wherever the cursor sits. Together they cover any line, but only if you put the cursor in the right place first.

There is no default key that clears the entire line

This is the part that catches people, and it is worth being precise about. Codex CLI has a distinct "kill whole line" action — one that wipes the line regardless of where the cursor is — but it ships with no key bound to it. The action exists and is available to assign; nothing triggers it out of the box.

So Ctrl + U is not quite a clear-line key. It is a clear-backwards key that behaves like one whenever your cursor is at the end. Move the cursor into the middle of a long prompt, press it, and you keep everything to the right.

If you want a true one-key wipe, bind it yourself in ~/.codex/config.toml:

[tui.keymap.editor]
kill_whole_line = "ctrl-shift-u"

Pick a key that is not already reserved. Codex refuses the whole keymap and tells you which action owns the key rather than quietly dropping your binding, so a bad choice fails loudly — which is the good outcome.

Clearing a word at a time

Often you do not want the whole line, just the last thing you typed. Ctrl + W deletes the previous word, and Alt + Backspace does the same. Hold either down and you walk backwards through the prompt a word at a time, which is usually faster than clearing everything and starting over.

Ctrl + Y pastes back the last thing you deleted, so an accidental Ctrl + U is recoverable. That is worth knowing before you retype a long prompt from memory.

Clearing the input is not the same as clearing the conversation

Three different things get called "clear" in a terminal agent, and they are worth separating:

  • The input lineCtrl + U. Your typed text, not yet sent.
  • The terminal displayCtrl + L. Scrollback only; the conversation is intact and Codex still remembers it.
  • The conversation itself/new starts a fresh one without leaving Codex.

If your goal is "make Codex forget what we were talking about", none of the key presses do that — the slash command does.

The rest of the keymap

Codex CLI's line editing follows readline conventions closely: Ctrl + A and Ctrl + E jump to the start and end of the line, Alt + B and Alt + F move by word, and Ctrl + J inserts a newline without sending. The Codex CLI cheat sheet has the full set in one printable page.