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