The redo command in Visual Studio Code lets you reapply changes you just undid—essentially reversing an undo. It restores the last action that was undone, returning your editor state to what it was before the undo occurred. This works immediately after an undo and depends on VS Code’s built-in undo/redo stack. No extensions or setup are required; it’s built into the editor by default.

What You'll Need

  • A recent version of Visual Studio Code (any current stable release: v1.0+)
  • A file open in the editor where you’ve recently made edits and performed an undo
  • No additional extensions or permissions needed

Step-by-Step

  1. Make a change in a file open in VS Code. For example, type a new line of code, delete a character, or move a block of text.
  2. Undo the change using one of the supported undo methods: press Ctrl + Z (Windows/Linux) or Cmd + Z (macOS), or go to Edit > Undo from the top menu bar. The change you just made will be reversed.
  3. Immediately after undoing, trigger the redo command. Use the keyboard shortcut Ctrl + Y (Windows/Linux) or Cmd + Shift + Z (macOS). Alternatively, select Edit > Redo from the menu bar.
  4. Verify the redone change. Your cursor and content should now match the state *before* you performed the undo—i.e., the original edit (like the newly typed line or deleted character) reappears.
  5. Repeat as needed. You can redo multiple steps, but only in the order they were undone. If you undo twice, you must redo twice to return to the current state. Note that performing a *new* edit after an undo clears the redo stack, so you cannot redo past that point.

Common Mistakes

  • Waiting too long after an undo. VS Code retains the redo stack only until you start a new edit. If you switch files, save, or type something new, the redo history is cleared.
  • Using the wrong macOS shortcut. Many assume Cmd + Y works like on Windows, but macOS uses Cmd + Shift + Z for redo. Cmd + Y is often unassigned or mapped to something else (like search forward).
  • Expecting redo after saving or closing. Redo only works within the current editing session. If you save the file and later reopen it, the redo stack is lost—even if you haven’t closed VS Code, switching to a different unsaved file also resets the stack for that buffer.
  • Confusing undo with undo to save. Some users think Ctrl + Z until the file reverts to its last saved state, then expect redo to restore unsaved changes. This only works if those edits are still in the undo/redo stack; VS Code does not preserve undo history across saves unless you use workspace settings to extend it (see Tips).

Tips

  • Stack depth matters. By default, VS Code keeps up to 300 undo/redo steps per file. You can increase this limit to retain more history: open Settings (Ctrl + , / Cmd + ,), search for undo, and adjust Editor: Undo Redo Stack Size to a higher number (e.g., 1000). This helps if you frequently undo/redo many steps.
  • Use the Command Palette for clarity. Press Ctrl + Shift + P (or Cmd + Shift + P on macOS), type redo, and select Redo. This confirms the command name and avoids shortcut confusion.
  • Redo works in multiple cursors and inline suggestions. Even if you used multi-cursor editing or accepted a Copilot suggestion, redo will restore those actions if you undo them first.
  • Check your keybinding. If your redo shortcut feels unresponsive, open File > Preferences > Keyboard Shortcuts (or Code > Preferences > Keyboard Shortcuts on macOS), search for redo, and verify the shortcut is set correctly. Conflicts with other extensions (e.g., Vim mode) can override defaults.

Troubleshooting

  • Redo does nothing. First, ensure you’ve actually performed an undo recently. Try undoing again (press Ctrl + Z), then immediately redo. If it still doesn’t work, type a new character—this creates a new edit point and may refresh the stack. If the issue persists, restart VS Code.
  • Shortcut has no effect. On Windows/Linux, confirm Ctrl + Y isn’t intercepted by another program (e.g., a screen capture tool or terminal multiplexer). On macOS, test Cmd + Shift + Z in a new, blank file to rule out workspace-specific keybindings. You can also reset keybindings by clicking the Reset Keybindings button in the Keyboard Shortcuts editor.
  • Redo restores the wrong state. This usually means you performed a *new* edit after undoing (e.g., you undid twice, then typed something, then pressed redo). VS Code only redoes the *last undone action*, not the entire stack. To recover, undo again to step backward, then redo in sequence.
  • After a crash or force-quit. VS Code does not persist undo/redo history across sessions. If the editor closed unexpectedly, redo is impossible—rely on version control (like Git) to restore previous states instead.
  • Extension interference. Some extensions (e.g., code linters, refactoring tools) trigger auto-edits that clear the undo stack. Temporarily disable extensions via View > Extensions to test if one is causing the issue. Use the Developer: Reload Window command to restart cleanly.

Frequently Asked Questions

Can I redo after saving the file?

No. Saving the file does not automatically preserve the undo/redo stack. Once the file is saved and you make a new edit, the redo history for prior unsaved changes is lost. To avoid this, use Git or VS Code’s local history extension to track unsaved edits.

Does redo work in integrated terminals?

No. The redo command only applies to text editing in the editor pane. In the integrated terminal, Ctrl + Y (or Cmd + Shift + Z on macOS) does nothing unless you’re using a terminal-based editor like Vim or Nano, where key mappings differ.

What’s the difference between undo and redo?

Undo reverts the most recent action (e.g., deleting text), moving backward. Redo reapplies the last undone action, moving forward in the history. They are symmetric: redo only works *after* an undo and only for actions still in the stack.

Can I redo multiple steps at once?

No. You must redo one step at a time. If you undo five times, you need to press redo five times to restore your original state. There’s no built-in way to jump to a specific point in the stack.

Why does my redo shortcut open the search bar instead?

On macOS, Cmd + Y is often bound to Find in Selection or similar, not redo. The correct redo shortcut is Cmd + Shift + Z. Check Keyboard Shortcuts to confirm or reassign it.

Does VS Code’s redo work the same in remote or container environments?

Yes. Whether you’re using SSH, GitHub Codespaces, or a Dev Container, the undo/redo stack is handled client-side by VS Code, so the redo command behaves identically across environments as long as the editor is active.