VS Code

How to Redo in VS Code (Shortcuts and Fixes)

How to Redo in VS Code (Shortcuts and Fixes)

Press Ctrl+Y on Windows and Linux, or Cmd+Shift+Z on macOS, and VS Code puts back the last change you undid. Edit > Redo does the same thing from the menu, one undo step per press, in whichever file has focus.

Since version 1.52 (VS Code release notes, November 2020), the Explorer keeps its own undo and redo history for file operations, separate from the editor’s history. The focused area decides which history responds.

How to redo in VS Code

Redo reapplies edits that undo reverted. Each press steps forward one undo step, and when there’s nothing left to restore, it stops.

SystemDefault shortcutSecond binding
WindowsCtrl+YCtrl+Shift+Z
macOSCmd+Shift+ZNone
LinuxCtrl+YCtrl+Shift+Z

Keyboard shortcut by operating system

The default keyboard shortcuts reference in the VS Code documentation lists redo under the command ID redo, with Cmd+Shift+Z on macOS and Ctrl+Y on Windows and Linux.

Windows and Linux also bind Ctrl+Shift+Z to the same command as a second key. Run Preferences: Open Default Keyboard Shortcuts (JSON) from the Command Palette and you’ll see both entries.

People coming from Word or Sublime Text often reach for Cmd+Y on a Mac, and it isn’t a default. Adding it takes one keybindings.json entry.

Redo acts on the file that has focus, so click into the editor before pressing the key.

Edit menu and Command Palette

You can skip the shortcut entirely. Edit > Redo in the menu bar works, and so does the Command Palette: press Ctrl+Shift+P (Cmd+Shift+P on macOS), type Redo, and hit Enter.

Both run the same command as the keys. They help when a remapped key or an unusual keyboard layout blocks the shortcut.

How the undo stack decides what redo restores

YouTube player

Each file keeps one linear history of edits. Undo walks backward through it, redo walks forward, and any new edit throws away everything ahead of it.

That’s why redo works right after an undo and stops the moment you type.

Say you type three lines, A, B and C, then undo twice. The file shows only A, and redo can bring back B and C. One redo gets you A and B. Type a new line D at that point and the file reads A, B, D. Line C is gone from the redo path, and redo has nothing left to apply.

The history lasts longer than it once did. Version 1.16 (August 2017) keeps the stack when a file reloads after a change on disk, according to the VS Code 1.16 release notes.

Closing a file got similar treatment in the VS Code 1.44 release notes (March 2020): the stack is kept, and reopening restores it as long as the contents have not changed since the close.

When redo does not work in VS Code

Most of the time redo is dead because you typed something after undoing. The other causes are rarer, and a few of them look identical from the editor.

CauseWhat you seeFix
New edit after undoRedo does nothingRestore from a saved version
Reopened file with changed contentsEmpty history after reopeningKeep contents identical between close and reopen
Restore setting turned offHistory lost on every closeSet files.restoreUndoStack to true
Shortcut conflictKey does nothing or runs another commandFind and remove the competing rule
Very long undo chainRedo stops partwayRedo in short bursts, then compare with the saved file

The first row is the common one, and the editor has no fix for it. Once a new edit cuts the history, the undone text can only come back from a saved version, through Local History or Git.

The microsoft/vscode issue tracker names files.restoreUndoStack as the global switch for restoring history on reopen.

Shortcut conflicts are the easiest to diagnose. Right-click the redo entry in the Keyboard Shortcuts editor and choose Show Same Keybindings to list every command on that key.

Rules are evaluated from the bottom up, and keybindings.json entries sit below the defaults, so a stray Ctrl+Y rule of your own beats the built-in redo. Run Developer: Toggle Keyboard Shortcuts Troubleshooting to log which command each key press triggers (VS Code keyboard shortcuts documentation, updated October 2026).

Focus matters too. If the cursor sits in a panel or a search box, redo acts on that control, not on the file. Click into the editor and press the key again.

The long-chain case is a user report, not a documented limit. Issue 325330 on the microsoft/vscode tracker, filed against version 1.128.0 on macOS, describes undoing roughly 100 steps and then redoing. Redo stopped partway and left only some changes reapplied.

After a long redo run, check the result with File: Compare Active File with Saved (Ctrl+K D on Windows and Linux), a command listed in the VS Code basic editing documentation.

How to recover changes after redo is lost

YouTube player

Once redo is gone, the text has to come back from a saved copy. Local History covers saved states of a single file and Git history covers committed versions. After an unexpected close, the hot exit backup is the other place to look.

RouteRestoresLimit
Local HistoryEach saved state of one file50 entries and 256 KB per file by default
Git history in the Timeline viewCommitted versions of one fileNothing newer than the last commit
Hot exit backupUnsaved text as it stood at closeThe final state only, not earlier steps

There’s one state none of these can bring back: text typed after your last save that a later edit cut off from redo. That text lived only in the redo path, and the path is gone.

VS Code backs up unsaved changes by default. According to the basic editing documentation, the backups sit in %APPDATA%\Code\Backups on Windows and $HOME/Library/Application Support/Code/Backups on macOS. Linux uses $HOME/.config/Code/Backups.

Local History and Timeline view

Open a file, expand the Timeline view at the bottom of the Explorer, and pick an entry. From there you can compare it, restore it, delete it or rename it.

Each entry holds the full contents of the file at the time of a save (VS Code user interface documentation).

The defaults are 50 entries per file (workbench.localHistory.maxFileEntries) and a 256 KB size limit for creating an entry (workbench.localHistory.maxFileSize). The merge window is 10 seconds (workbench.localHistory.mergeWindow), and it’s the one that bites. Two saves within 10 seconds leave a single entry, so the state between them is gone.

A deleted file comes back through the Local History: Find Entry to Restore action in the Timeline view menu.

Source Control and Git

Discard Changes removes work. It never recovers any.

Unstage keeps your edits in the working file and only pulls them out of the next commit. Undo Last Commit drops an unpushed commit from local history and leaves its changes staged. Discard Changes is the dangerous one, since it deletes uncommitted edits, and the documentation states that recovery is not guaranteed.

Discarded edits to tracked files skip the Recycle Bin and Trash, per the VS Code Source Control documentation. If you already discarded work, the Local History entries in the Timeline view are the fallback, and the same page calls them no guaranteed backup.

Where redo applies beyond the text editor

Redo isn’t limited to the text editor. The Explorer and parts of the chat experience have it too, each on its own history, and focus decides which one answers.

Explorer, notebooks and the terminal

VS Code 1.52 (November 2020) added undo and redo for delete, rename, copy, move, new file and new folder. The Explorer keeps a stack separate from the editor’s, and focus picks which stack acts, per the 1.52 release notes.

Notebooks are patchier. In command mode, the z key undoes the previous change, including a deleted cell, but the Jupyter documentation in VS Code names no matching redo key.

The integrated terminal passes shortcuts to the shell unless the command sits in terminal.integrated.commandsToSkipShell, so redo on a shell line comes from the shell’s own keys.

Test redo on a throwaway notebook cell before you rely on it.

Copilot edits

In edit mode, after you undo the last edit, a Redo Last Edit control in the Chat view title bar reapplies it, according to the older edit mode documentation. The chat.editing.confirmEditRequestRetry setting asks for confirmation before redoing the last edit, and that documentation gave its default as true. The edit mode page no longer exists as a separate page in the current VS Code docs, so check that your build still shows the control.

Checkpoints work differently. After you restore one, a Redo button recovers the changes that were undone. Checkpoints are on by default, temporary, and do not reverse completed terminal commands (VS Code review and revert documentation).

The two features undo different things, so they do not conflict. Neither one replaces Git.

Cursor undo and Vim redo

Cursor undo moves the cursor, not the text.

The default shortcuts reference binds the cursorUndo command to Ctrl+U (Cmd+U on macOS). Cursor redo ships without a default key.

Vim redo is Ctrl+R in normal mode. Community VSCodeVim configs on GitHub map keys to the editor’s own undo and redo commands through vim.normalModeKeyBindingsNonRecursive.

Changing the redo keybinding

The Keyboard Shortcuts editor is the quick way.

  1. Press Ctrl+K Ctrl+S (Cmd+K Cmd+S on macOS) to open the Keyboard Shortcuts editor.
  2. Type redo in the search box.
  3. Right-click the redo entry and choose Change Keybinding.
  4. Press the new key combination and confirm with Enter.
  5. Click into a file and test the keys.

If you’d rather edit JSON, select Open Keyboard Shortcuts (JSON) in the editor title bar and add a rule with a key, a command and an optional when clause. A new rule adds a key and leaves the default in place.

A reply in microsoft/vscode issue 641 gives the entry for Mac users who want Cmd+Y:

{ "key": "cmd+y", "command": "redo", "when": "editorTextFocus" }

Drop the when clause and the key works everywhere, because a rule without one is global (VS Code keyboard rules documentation). The editorTextFocus value limits it to a focused editor.

A minus sign before the command name removes a default, so { "key": "ctrl+y", "command": "-redo" } clears the Ctrl+Y binding.

Check what your build binds before you change anything. The default shortcuts reference page lists only Ctrl+Y for Windows and Linux, while the editor’s source code in the microsoft/vscode repository also registers Ctrl+Shift+Z as a second binding on both.

Show System Keybindings, in the More Actions menu of the Keyboard Shortcuts editor, settles it for your install.

To back out a change of your own, right-click the entry and choose Reset Keybinding, or delete the rule from keybindings.json.

Redo in VS Code FAQ

How do I undo in VS Code?

Press Ctrl+Z on Windows and Linux or Cmd+Z on macOS. The default shortcuts reference binds both to the undo command, and Edit > Undo runs the same action.

Does redo work in VS Code for the Web?

Yes. The VS Code documentation lists the browser shortcut conflicts, such as the Command Palette in Firefox and new file, and redo is not among them.

The desktop app is the option when you want a full set of shortcuts not limited by your browser.

Will my custom redo keybinding sync to another computer?

Yes, with one catch. Settings Sync stores keyboard shortcuts separately for each operating system by default, so a rule added on a Mac stays off a Windows machine until you clear the settingsSync.keybindingsPerPlatform setting.

Why do the redo keys look different on my non-US keyboard?

VS Code renders and records shortcuts using your current keyboard layout. Check the redo entry in the Keyboard Shortcuts editor for the keys your layout needs.

In keybindings.json, Ctrl+K Ctrl+K opens the Define Keybinding control, which shows the keys VS Code detects.

Keeping a Safety Net Beyond Redo in VS Code

Redo in VS Code protects only the history of the open session, so Auto Save, a recent Git commit and Local History have to cover everything else. As of the October 2026 documentation, Auto Save ships off, and File > Auto Save turns on saving after a 1000 ms delay.

Turn Auto Save on first, since every other safeguard depends on the file on disk holding your work. Commit before a large refactor, and leave files.restoreUndoStack enabled.

The cost is a weaker check. Once saves land after every 1000 ms pause, File: Compare Active File with Saved shows almost no difference, so it stops catching a bad redo run.

Bogdan Sandu

Stay sharp. Ship better code.

Every week: one curated article, one tool worth knowing, one tip you can use tomorrow. No noise, no padding.