Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

At the time this question was asked, version 10 was not out yet. The Front End of Mathematica 10 does have multiple undo, see the answer by John Fultz.

The Mathematica Front End's built-in Undo command can only undo a single editing step.

Has anyone implemented or seen implemented an efficient and comfortable multiple undo?

I have in mind ideas such as, CellEventActions that keeps a stack in the cell context pushing the cell state every time a key among a list (brackets, @, operators) is pressed. Some other shortcut to recover older states (or a palette, or perhaps tweaking the front end's .tr files??)

I am not familiar at all with typical text based implementations and their issues. I guess it wouldn't be a practical problem to lose the undo state between sessions, would it?

So, has this been done, or is it doable or practical? What are your thoughts?

share|improve this question
This certainly seems possible at least for the "Program" - style cells, and I have plans to integrate this as a feature in the next versions of the syntax highlighter, which you are probably familiar with. Since my highlighting engine is grabbing the cell's contents on every trigered event, this should be a relatively simple matter to do. One problem I face here is that I don't know how to trigger the CTRL key (or its equivalent on other platforms) yet. – Leonid Shifrin Feb 18 '12 at 21:41
@LeonidShifrin I would happily write Undo[] multiple times, don't let Ctrl get in your way. – David Mar 6 '12 at 7:35
I can't undertand. Why Mathematica is missing this? This action is extremly needed and useful. And missing until latest Mathematica versions. Lol. Why? Maybe someone should contact Mathematica and show this question for them. – GarouDan Jun 26 '12 at 19:03
2 – Tyilo Aug 24 '13 at 22:45
Now that Mathematica 10 has been released, note that among new features is: "Computation-aware multiple undo The problem of multiple undo in Mathematica has been solved!". See – murray Jul 9 '14 at 18:57

2 Answers 2

up vote 42 down vote accepted

I implemented a multiple undo mechanism in v10.

It's not as perfect as I would like it to be, yet, but it does a pretty decent job in my experience. And a few of the documented options for it got ahead of the implementation...think of some of that stuff as a "coming soon".

Feel free to ping me on any problems you find with it.

Edit: In 10.0.2, all of the documented options are implemented except for "SpoolDirectory".

share|improve this answer
I wish I could say "I-implemented-something" meaning it's part of Mathematica from now on :) – István Zachar Jul 11 '14 at 11:18
How perfect would you like it to be? As in what specific elements would you have liked it to have? – jVincent Jul 13 '14 at 20:23
@jVincent Speaking as someone who had to think about every aspect of the system, I'm always seeing lots of bugs and limitations, many of which might be rarely noticed outside of Wolfram. In some cases, things that should be undoable but aren't. In some cases, undo falls over and does the wrong thing (I have significant internal consistency checks that tend to prevent undo from causing harm, but it will stop and wipe the undo stack in such a case). But my own priority/embarrassment list might not match those found by users. So, we'll see what the community judgment is. :) – John Fultz Jul 15 '14 at 17:34
Awesome! First complaint: I should be able to hold down ⌘Z or ⇧⌘Z and have it repeatedly undo/redo :) – jtbandes Jul 17 '14 at 8:00
@jtbandes Thanks for the complaint (really!)...that's a pretty decent suggestion. It's odd that I've never tried that before despite the fact that I commonly do it in text editors. – John Fultz Jul 28 '14 at 0:57

I made a simple version control and undo function. (Since it uses system commands right now it is only tested for Linux. Windows support is added but not tested. MacOS is not tested either.)

Here is the link to undo.m or the github if you just want to try it (and trust me enough to run the code without checking) run


Would be great to have some feedback with ideas how to improve it, also I didn't test this a lot but it seems to be working fine. It is probably not the most efficient way but I think it is a good start.

From the readme:

This package adds a poor mans version control and undo functionality to Mathematica. For a previously saved notebook 'notebook.nb' a version info file '' is created and every time changes are committed a backup file 'notebook.nb[version].bak' is created. System menu entries in insert are created.

Keyboard Shortcuts

Alt+z : Undo

Alt+x : Redo

Alt+s : Commit

Alt+d : Opens CommitInfo Dialog

Usage: Evaluate the following commands

ManualCommit (Default) - Only do commits manually.

AutoCommit - Turn on automatic commits. Every time a cell is evaluated a new commit is made. (This can lead to a lot of files)

CronCommit[n] - makes a new commit every n minutes.

CommitNow - Making a commit CommitInfo - Show a list of all Versions CommitClean - Remove all commited files

Undo - Undo to the previous commit Redo - Undo to the next commit GotoCommit[n] - Go to the n-th version


When altering not the latest version, the changes (when running undo or redo) are not saved, only when running 'commit' these changes are changed (with a new highest version number). Only changes to the version with the highest version number are changed upon 'undo'

Whether a commit needs to be made when running undo is checked with a system variable that can be altered by manually saving the document. Leading to possible loss of changes. For best results do not save the notebook manually and turn auto save off - just use commit to save the work.

EDIT: This version also has problems with individual context for each notebook, so just be warned. :)

share|improve this answer
thanks to Chris Degnen for helping with the keyboard shortcuts.… – jens_bo Dec 12 '12 at 16:04
from looking at the code, it should work under OS X (the default shell is bash) – acl Dec 12 '12 at 22:48

protected by R. M. Feb 6 '13 at 4:52

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.