← Claude Code Hub
✦ Tip #186 Sep 3, 2026

Undo in Claude Code: Ctrl+_ takes back what you typed, /rewind takes back what Claude did

You wiped half a prompt by accident and assumed it was gone. It isn't: Ctrl+_ steps back through what you typed, up to fifty times, cursor and pasted content included. And it has nothing to do with /rewind.

Two undos in Claude Code: Ctrl+_ steps back through what you typed in the input box, up to fifty steps; /rewind steps back through what Claude changed in files and conversation. They never touch the same thing

TL;DR Ctrl+_ (also Ctrl+-, Ctrl+Shift+- and Ctrl+Shift+_) undoes the last edit in the input box: up to fifty steps, one per second of pause, with text, cursor and pasted content. Submitting clears it and there is no redo. Whatever Claude already changed in files or in the conversation is /rewind's job.

You're twelve lines into a prompt, you select the wrong span, hit a key, and half a line is gone. In an editor you'd press undo without thinking. In the terminal the usual move is a sigh and retyping it from memory, because "undo" in Claude Code sounds like /rewind, and /rewind is something else.

The input box has an undo of its own. It's in the prompt help (the one you open with ?), listed as undo, and in one row of the docs' shortcut table, with nothing more said.

Result (illustrative; the cursor is ):

> review the login and check that the refresh token expires after 15 min▮

   ...wrong selection, overwritten...

> review the login and c▮

Ctrl+_

> review the login and check that the refresh token expires after 15 min▮

How it works

1. It snapshots as you type. Every change to the input box goes into a buffer of fifty states. Each state carries the text, the cursor position and the pasted content, so stepping back also brings back an image you had pasted. At fifty-one, the oldest one drops off.

2. With a one-second grace period. It doesn't record every keystroke: it groups what you type in a run and takes the snapshot once you've gone one second without touching anything. That's why one Ctrl+_ gives you back a word or a phrase, not a letter. The exception is vim mode: outside INSERT, every operation is recorded on the spot.

3. It goes back, never forward. Each press steps one state back. There is no redo: overshoot and the only way forward is typing it again.

4. It clears on submit. The buffer lives as long as the draft does. The moment you press Enter, or a slash command finishes, it's wiped. It doesn't survive the session either.

The four key combinations

The binary carries four shortcuts pointing at the same action, chat:undo:

ctrl+_    ctrl+-    ctrl+shift+-    ctrl+shift+_

The docs list two. The other two exist because every terminal sends a different sequence for the same physical key: on some, Ctrl plus the hyphen arrives as ctrl+-, on others as ctrl+_. The help shows you a single one, whichever is bound, though all four work. If none of them responds, your terminal is swallowing it; /keybindings shows you what's bound and lets you remap it:

{
  "bindings": [
    { "context": "Chat", "bindings": { "alt+u": "chat:undo" } }
  ]
}

What you don't want is Ctrl+Z, which is what the hand reaches for: on Unix it suspends the process, and the docs list it among the shortcuts that collide with the terminal. And if you pick one with Alt on macOS, your terminal has to send Option as Meta.

Four keys that look alike and aren't

You want to Key What it touches
Undo the last thing you typed Ctrl+_ The input box, one step back
Clear the box and recall it with the up arrow Esc Esc The input box, whole, into history
Park the draft and ask something else Ctrl+S The input box, into a separate slot
Undo what Claude changed /rewind Files and conversation, by checkpoint

The first three never touch a file. The fourth never touches the input box. Esc Esc sends the whole draft to history and you lose the cursor position; Ctrl+S parks it in a slot and hands it back when you submit the next prompt. Ctrl+_ is the only one that goes back one step, not all of them. And /rewind is what comes up when you search "claude code undo": it undoes what Claude did, and knows nothing about what you were typing.

Official docs: Interactive mode: keyboard shortcuts · Keybindings

Requirements

  • Checked on Claude Code v2.1.258. The fifty-state buffer and the one-second debounce come from the binary itself; the docs only say it restores text and cursor.
Workshop for teams

Multiply your team's output without sacrificing quality: a 6 to 8 hour AI First workshop, online, on the Claude platform.

See the workshop
Free guide

The 51 essentials, as a PDF.

One page per tip. Five chapters. What I actually use daily in production — no theory, no fluff.

  • I. Getting started 10 tips
  • II. Awareness 3 tips
  • III. Mastery 22 tips
  • IV. Autonomy 10 tips
  • V. Comparison 6 tips
Are you a professional Web developer?

You'll receive the guide by email · You join the Gravitas newsletter · Unsubscribe anytime

of 51
#

Wmedia · 51 Tips
Free guide · 51 tips · 5 chapters

The 51 essentials, as a PDF.

Are you a professional Web developer? · Unsubscribe anytime