[vim] Reuse codemirror instance across tests when sensible

I promised to look into reusing `cm` instances across tests in the vim mode a while back. This patch moves a few things around to make it work.

Based on unscientific measurements on my laptop, it shaves ~1 second off of a total of ~22 seconds of running the entire suite. To me, a <5% speedup doesn't seem worth the lack of isolation between tests. What do you think?