Remove CellMargins option from many cells

I have a very old notebook in which many cells had the CellMargins option set manually. What's the easiest way to remove all those manual option settings?

-
@R.M I think it only looks for incompatibilities, and I'm guessing CellMargins has been around for a long time. –  tkott Apr 28 '12 at 21:39
@R.M.: no, the compatibility check does $not$ ask about CellMargins. After all, that's a legitimate cell option still. –  murray Apr 28 '12 at 21:40

Add the following line to the end of the notebook you want to update:

NotebookPut[NotebookGet[] /. Verbatim[Rule][CellMargins, e__] -> Sequence[]];


And evaluate it. You should get a new notebook for which all CellMargins have been deleted.

Looks like you can use the UI pretty easily to do this. First, highlight all the cells (if you want all the cells to have the same margins, just hit CTRL+a.

Then, go to Format -> Options Inspector (also can use CTRL+SHIFT+O). In the search box, you can type in CellMargins:

Here, I've set the marings to be {{66,10},{5,25}}. It looks like the default is {{66,10},{5,10}} and the settings are {{left,right},{top,bottom}}

-
I did $not$ ask how to change the CellMargin option (I certainly know how to do that using the Options Inspector). I want to $remove$ the option entirely from all cells (so that the margins will be whatever the stylesheet sets by default). –  murray Apr 28 '12 at 21:42
@murray All cells have the CellMargins attribute, I don't think you can "remove" it. Do you mean you would like to restore it separately for each cell type that it is in? I.e., an input cell has the default style for the default stylesheet? If so, that certainly wasn't clear from your question, and questions for which users don't know about the options inspector have come up, so I don't know how I could've known all that. –  tkott Apr 28 '12 at 21:47
No, all cells do $not$ have a CellMargins attribute as part of their expression--although of course they are in effect given cell margin settings by the cell style. E.g., in a new nb create any Input cell then look at its expression; you will $not$ see any CellMargins option there! –  murray Apr 28 '12 at 21:52
@murray not all cells have an explicit CellMargins, but I believe the front end keeps track of it as a default. But I do see what you mean: see my edit. –  tkott Apr 28 '12 at 21:59
@murray, the little cross at the left of the options in the options inspector, when removed, removes the explicit option settings, and shows whatever value is inherited. Now you certainly know how to remove the options using the options inspector too –  Rojo Apr 28 '12 at 23:16