Skip to content

Feature Request - Make possible to undo (redo) changes in code after VS Code's been restarted #43555

Open

Description

@user3323
  • VSCode Version: 1.21.0-ins
  • OS Version: win7x64

It would be great to undo (Ctrl+Z) and redo (Ctrl+Y) changes in the code we've done, after VS Code's been closed and restarted.

Is it hard to implement?

Activity

  1. added
    editor-core
    on Feb 13, 2018
  2. added
    feature-request
    and removed on Feb 13, 2018
  3. cmmp commented on May 11, 2018

    @cmmp

    I think it would be a very useful feature. I also don't think that the subsequent drawback as mentioned is really an issue, since if there is infinite ctrl+z there should be infinite redo (CTRL+Y) as well, allowing you to return to whatever state the file was opened.

  4. airato commented on Oct 19, 2018

    @airato

    In my opinion closing/opening a tab in vs-code is not perceived as closing/opening a file, it's just a tab which can be opened and closed for the same file many times. and the fact that closing a tab has side effects is not clear, and users have to learn that on their own after they lose their changes few times.
    And there still will be Ctrl+Shift+Z to go back and forth.

    this feature is needed since it's counterintuitive that Ctrl+Z history disappears when you for example Reload window, or even close a tab and open it back. I would even qualify current state as a bug, not as a feature.

  5. spacepluk commented on Oct 19, 2018

    @spacepluk

    This is one of the things that are keeping me in vim. I don't think the subsequent drawback mentioned above is a problem especially when you are using git or other vcs.

  6. Dominik-K commented on Dec 31, 2018

    @Dominik-K

    Undo/redo after file or tab closing, not VSCode reload or restart, is discussed in #7169 (Ahmed-Hussein-Karam, Airat Aminev (@airato)).

  7. zwhitchcox commented on Jan 14, 2019

    @zwhitchcox

    I recently switched from vim to vscode, and this is the only extremely useful feature that is not included in VS Code.

    I don't know if Ahmed-Hussein-Karam has ever actually had persistent undo, but it is absolutely amazing.

    I'm not going to be able to do it justice if I try to explain all the benefits verbally, but just trust me, it's earth-shattering.

  8. ivolucien commented on Jun 18, 2019

    @ivolucien

    Full undo / redo for both tab and vscode restarts would be amazing!

    IMO it should be off by default but supported by turning on a config flag.

  9. vpalos commented on Jun 26, 2019

    @vpalos

    Before VSCode, I used Atom.io for a short while. I absolutely loved moving to VSC, but the only thing I truly missed was this: https://atom.io/packages/persistent-undo.

    This feature would be just amazing!

  10. mh-firouzjah commented on Jul 5, 2019

    @mh-firouzjah

    And any new news ?
    Is that bug still there?

  11. 2 remaining items

  12. mkanet commented on Aug 4, 2019

    @mkanet

    Is there an extension that will do this? I'm not even sure what to search for.

  13. removed their assignment
    on Aug 5, 2019
  14. dannyfranca commented on Aug 30, 2019

    @dannyfranca

    Is there an extension that will do this? I'm not even sure what to search for.

    I don't think so, it's a core feature

  15. dannyfranca commented on Aug 30, 2019

    @dannyfranca

    At least when we close a tab, the history should remain, similar to WebStorm. Not necessarily after reloading VSCode itself, but it's a great feature.

  16. haifengkao commented on Oct 7, 2019

    @haifengkao

    I think we can make persistent undo by modifying local-history and remap the undo and redo key.

    We only need a brave hero to implement it

  17. rahmanunver commented on Dec 12, 2019

    @rahmanunver

    And that hero never came.

  18. phil294 commented on Apr 11, 2020

    @phil294

    The undo history is now preserved when you close a tab. Not the case for restarting vscode entirely though.

  19. nodehead commented on Apr 12, 2020

    @nodehead

    Is anyone aware of a way / is there a way to disable the new undo stack behavior? A search of settings doesn't show anything obvious, and the update note doesn't list any settings.

    While I certainly see why this would be useful, and desirable, it is also a major change in default behavior if there is no opt-out setting. Perhaps it's just me, but I frequently open a file, trying something, then discarding it by holding down CTRL/CMD + Z and expecting that to return the file state to where it was on open.

    I accidentally undid committed changes today with the new behavior -- not the end of the world, and easily remedied once I realized what had happened, but slightly annoying.

    Edit: to be clear, not complaining about the feature in any way, just wondering if there is a way to return to the old behavior that I haven't found.

  20. phil294 commented on Apr 12, 2020

    @phil294

    Profile (@nodehead) There is a seperate issue for the new undo mechanic: #7169, while this one is about preserving the changes after IDE restart.

    Making the new mechanic configurable is also shortly discussed in that issue, and #94778 is the continuation. You'll probably want to participante in there.

  21. mstgnz commented on Apr 26, 2020

    @mstgnz

    friend I just want to undo the changes made with the file open. why did you request such a thing? he says back all the time. I want to come back to the last registered yield. going back to the last commit. Doesn't it have a setting?

  22. phptek commented on May 13, 2020

    @phptek

    Is it just me that finds "persistent undo" the weirdest thing ever? It's like expecting the bottom of the stairs to arrive in a block of flats on ten floors, but going down past that to the 20th and beyond!

    As Profile (@nodehead) said pretty well - this should be configurable. Several times I've undone committed changes which is just plain weird! I used Netbeans since forever (and heaps of standard text editors) the default is "sane": If you've closed a tab or a window, you closed the file. EOS.

    If you want a config setting to enable that (and maybe I'm just too old, but I ask "why would you"?) then fine, but don't make it a default and/or provide a setting to control this so VSC behaves like a "standard" editor.

    Thx team :-)

  23. boltex commented on Aug 13, 2020

    @boltex

    Re-pasting my question here because it is somewhat related. I need to prevent undos from persisting!

    My extension (https://github.com/boltex/leointeg) uses file system api to implement custom 'editors' for my needs as indicated in the docunmentation here https://code.visualstudio.com/api/extension-guides/virtual-documents#file-system-api .

    I need to be able to 'block' or 'clear' undos when closing or switching from one of them to another.

    It used to be that doing vscode.WorkspaceEdit "rename" operation would 'clear'/'block' all undos for the newly named document to traverse across the point where the document was renamed, but lately the newer versions of vscode tries to open a document with the old name when pressing ctrl+Z on a newly renamed document (in a custom filesystem)... Is there a way to disable that? Or a way to clear the undo stack for a given document URL? or for a filesystem scheme only in particular?

    Thanks to anyone who can clarify 'undo stack' persistence behavior!

  24. ivolucien commented on Aug 25, 2020

    @ivolucien

    Is it just me that finds "persistent undo" the weirdest thing ever? It's like expecting the bottom of the stairs to arrive in a block of flats on ten floors, but going down past that to the 20th and beyond!

    Russ Michell (@phptek) - FWIW persistent undo is "new" on the scale of it, at least 10 years old for vim. My comment in my above ticket, June 2019, suggests that persistent undo be off by default since it's a big change in behavior. vim's version is smart in that any non-vim change to the file, even metadata IIRC, resets the undo stack. So if you've pulled a new branch or even touched the file the undo is reset.

  25. gaoqiangks commented on Aug 6, 2025

    @gaoqiangks

    It's 2025 now, still open?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    editor-corefeature-requestundo-redo

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions