Fix multiline edits

It appears that edit.py has problems when you queue up a ton of
inserts and erases. Work around this by using one edit per line,
and gluing liberally.
Fix history checking for glued commands

Unfortunately undoing is a little bit wonky - it looks like each
character takes two undos: one for the current line, and one for
the other lines. Not sure why yet.