Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Line Undo/RedoNew to Visual Studio Code? Get it now.
Line Undo/Redo

Line Undo/Redo

Gilbert Zenner

| (0) | Free
Undo/redo history tracked per line, per file, instead of one global undo tree.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Line Undo/Redo

Undo/redo tracked per line, per file, instead of VS Code's single global undo tree.

Type in one line, jump to another line and type there, then come back and press Line Undo: it undoes only that line's last change, not whatever you typed elsewhere in between.

Commands

  • Line Undo/Redo: Undo Current Line (Ctrl+Alt+Z / Cmd+Alt+Z): reverts the line the cursor is on to its previous content.
  • Line Undo/Redo: Redo Current Line (Ctrl+Alt+Y / Cmd+Alt+Y): reapplies a change that was just line-undone.

VS Code's normal Ctrl+Z / Ctrl+Y still work as before and are untouched.

How it works

The extension keeps a small undo/redo stack per line number per open document. Consecutive keystrokes on the same line within ~800ms are coalesced into one undo step (like normal typing feels in VS Code), so you don't have to press undo once per character.

Limitations

  • Edits that span multiple lines (pasting a multi-line block, deleting a selection that crosses lines, pressing Enter) reset the per-line history for that file, since line numbers shift and old per-line snapshots would no longer line up correctly. Plain single-line typing/backspacing is fully tracked.
  • History is in-memory only and is lost when a file is closed or VS Code restarts.

Running it

  1. Open this folder in VS Code.
  2. Press F5 to launch an Extension Development Host with the extension loaded.
  3. Edit some lines, jump around, and try the two commands from the Command Palette or their keybindings.

Packaging

npm install -g @vscode/vsce
vsce package

This produces a .vsix you can install via Extensions: Install from VSIX....

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft