tl;dr Google Docs + Vim = Yay.
Ah, the grail. Vim everywhere. Once Vim's got its claws in you, you can't settle for anything else. Every other editor is frustrating and second-class.
But for for Google Docs I'm forced to make an exception. It's my ideal way to work with normal peoplegeek. Especially when it's changing a lot. Google Docs is user-friendly, it's got all the features we need, and no-one ever stops the conference call to say, "Wait - did I email you the latest version?"
But I still don't want to give up Vim. How could we connect the two? The way I see it, there are three possible solutions.
We could build a plugin for Vim that connects to the Google Docs server. Ever since Google Wave came & went, there has been plenty of information available on how to build a collaborative document-editing system. We can assume that Google Docs approaches the problem along these lines. The problem I think, wouldn't be with the protocol, but with Vim itself.
Vim is single-threaded, so it's not going to lend itself well to listening asynchronously for changes from the central server. We could probably work around that by reaching out from Vim into Python or Ruby, but that instantly puts us into the realms of, "If this plugin doesn't work, simply re-compile your copy of Vim." Yuck.
Also, Vim has a strictly text-only display. Even if we could happily listen for changes, displaying them is going to be tricky. We could use some syntax-highlighting tricks to simulate multiple cursors, but I think it's always going to look like a hack.
I don't think building Google Docs collaborative editing into Vim is impossibleexisting, but I'm certain it would be swimming against the tide. Getting it to work well would be a mammoth project.
Emacs has a very good Vim-emulation mode, and copes well will multiple processes and displaying text-with-extrasmultiple. It would be possible. In fact, I've built a prototype myself, and whilst it's not releasable, it certainly proves the concept. But it puts us in an even worse position: "To install this plugin, just install Emacs." I can't see any Vim user accepting that as a solutionemacs.
Another way forward would be to bypass both Vim & Google Docs for something Vim-like and Google Docs-like, that's better suited to the task. There are a few online editors that offer collaboration, and several of them are based on CodeMirrorcodemirror, which has a passable Vi-emulation mode.
This is probably the shortest path to a solution, but it still suffers from our opening problem: You have to turn to your non-technical colleagues and say, "Can we switch from Google Docs just so I can use Vim?", and they look at you like you're an alien. No, the right solution won't involve having to change an existing team's behaviour just to accommodate our preferences.
So the last solution, and I think the only viable one, is to graft a Vim-like input system on top of Google Docs. If we do that, we don't have to disturb existing users, we ought to get live collaboration & display for free, and we just have to worry about one key problem: How much Vim do we need? How much would we have to implement before we felt at home in Google Docs?
Naive Vim extensions rarely seem to get much beyond
ESC, h, j, k, l
before they think they've got the essence of Vim. We know there's
much more to it. With that in mind, here's my list of what we'd need,
and a few things I think we can leave out:
d5jshould delete 5 lines.
ci(should change all the text in the current parentheses.
:wordcountshould trigger the word-count box.
:helpshould trigger the Google Docs help.
I think it would be the right approach. I think it would be a reasonably-sized project. I think it would make the world a better place. So I'm putting the idea out into the world. What do you think?