Refactored slightly and implemented OnTheFlyFormat

This is really just in-line replacing text rather than deferring to the
upstream formatter, this seems to give an undo level for document based
formatting which wasn’t present before.