You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request - Make possible to undo (redo) changes in code after VS Code's been restarted #43555
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?
Reacted by Yurii Holskyi, Cássio M. M. Pereira, Flo Rida, hupeky, grizzly.web, lumiliet, Aanchal Sharma, Eric Hynds, chris montgomery, Ayon Saha and 144 more
Reacted by Yurii Holskyi, Eric Hynds, Airat Aminev, Taha, J.Fischer, George Crabtree, Zane Hitchcox, suzetmk, Gamunu Balagalla, simdimdim and 30 more
Reacted by Aesthetic Vulpes, 9thDuck, Ricky Boyce, sovai, amandin, aelkin and Alexander Adam
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.
Reacted by Airat Aminev, Yurii Holskyi, GrailFinder, Zane Hitchcox, Philipp Dörfler, suzetmk, Daniel Johnson, Valeriu Paloş, Ivo Havener, MKANET and 15 more
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.
Reacted by Yurii Holskyi, Guillaume, JRousse, Šimon Let, LY, Valeriu Paloş, Zane Hitchcox, Ivo Havener, desmap, Isaiah Odhner and 13 more
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.
Reacted by Spencer Wood, maricn, Zane Hitchcox, Ivo Havener, Luan Bitar, Žiga Šebenik, Aiden, ZenMagus, Diamond, Andrew and 5 more
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.
Reacted by Scott Baxter, Matt Camilli, Pavel Karatsiuba, Ivo Havener, Žiga Šebenik, dallanlee, Aiden, Simon Fontana Oscarsson, Alok Singh, Andrew and 3 more
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.
Reacted by Ethan Sharabi, Loïc KARTONO, Russ Michell, bruno and Danny Asmussen
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.
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?
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 :-)
Reacted by Alok Singh, allonli, Juan Campa, awsms, Ricky Boyce, Tec Fu, MKANET and Tommaso Thea Cioni
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!
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.
Activity
cmmp commentedon May 11, 2018
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.
airato commentedon Oct 19, 2018
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.
spacepluk commentedon Oct 19, 2018
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.
Dominik-K commentedon Dec 31, 2018
Undo/redo after file or tab closing, not VSCode reload or restart, is discussed in #7169 (Ahmed-Hussein-Karam, Airat Aminev (@airato)).
zwhitchcox commentedon Jan 14, 2019
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.
ivolucien commentedon Jun 18, 2019
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.
vpalos commentedon Jun 26, 2019
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!
mh-firouzjah commentedon Jul 5, 2019
And any new news ?
Is that bug still there?
2 remaining items
mkanet commentedon Aug 4, 2019
Is there an extension that will do this? I'm not even sure what to search for.
dannyfranca commentedon Aug 30, 2019
I don't think so, it's a core feature
dannyfranca commentedon Aug 30, 2019
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.
haifengkao commentedon Oct 7, 2019
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
rahmanunver commentedon Dec 12, 2019
And that hero never came.
phil294 commentedon Apr 11, 2020
The undo history is now preserved when you close a tab. Not the case for restarting vscode entirely though.
nodehead commentedon Apr 12, 2020
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.
phil294 commentedon Apr 12, 2020
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.
mstgnz commentedon Apr 26, 2020
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?
phptek commentedon May 13, 2020
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 :-)
boltex commentedon Aug 13, 2020
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!
ivolucien commentedon Aug 25, 2020
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.gaoqiangks commentedon Aug 6, 2025
It's 2025 now, still open?