How to group macro actions into a single undo step?

I am running a macro that performs several actions on some text. If I want to undo the macro, I have to undo several times to fully revert to the previous state.

Is there a way to group all the actions into a single undo step?

Hallo

'#snip
    undo = doc.getUndoManager()
    undo.enterUndoContext("give it a Name")
    '# do the stuff you want todo
    undo.leaveUndoContext()
4 Likes

Works perfectly. Thanks.