MATLAB: How to undo a delete

editorundelete

How do I undo an accidental delete when using the editor for a .m file, or alternatively retrieve the .m file from before the accidental delete?

Best Answer

It depends on what you deleted. If a bit of code in the .m file you’re editing, in the very top Editor taskbar near the right end, there are two curved arrows. Clicking on the one that points to the left will undelete inadvertently deleted text.
For .m files, depending on the preferences you have set (particularly autosave), you might find the complete or earlier version of it with the same prefix and an .asv (instead of .m) extension. Otherwise for a deleted .m file, on Windows machines look in the Recycle Bin. (No guarantees — I’ve not done that so I have no personal experience — but that is where I’d look.)
Related Question