July 2, 2009 7:30pm
I've been a vi and Vim user for a long time. As such, my most productive writing comes when I'm using my beloved modal editor. I'm also a long-time Mutt user, the main attraction being that I can edit my mail with Vim. Recently, I've started using GMail for my non-academic mail, so I can more cleanly drop into academic mode without distraction.
GMail is much better than Mutt at a couple of important things, the most obvious being search. Searching all your mail is a pain to set up in Mutt, but the simplest thing in GMail. Mutt is also quite slow opening large mailboxes, and it's impossible to save the same message in multiple 'places', as you can with GMail's labels.
But I really missed being able to write email in Vim. Good email communication requires chopping out stuff that's irrelevant to your reply, and snipping that stuff and keeping it readable is infinitely easier in Vim than in the pointy clicky world of a browser's textarea1.
While editing a long and involved email today, I pined on identica for Vim editing in GMail. I wasn't really expecting anyone to be able to suggest how I might achieve that but I quickly got a couple of useful leads. penryu suggested vimperator, which was supported by notjosh. Vimperator is an extension that makes Firefox behave in a kind of Vim-like way. I gave it a try but I couldn't work out how to use it as an editor for textareas2, and it seemed to have a bug (or possibly a conflict with the diigo toolbar) that meant I couldn't see anything I entered in Normal mode. So I ditched vimperator.
I had a small side journey looking at jsvi, a JavaScript reimplementation of vi, which I might revisit later to make a jQuery plugin, and extend that into a Habari plugin, but decided that was more than I wanted to do for the moment.
Next, screwtape and gavincarr suggested the It's All Text extension for Firefox. I managed to get that hooked up to MacVim (I couldn't get gvim to work) using the full path to the MacVim binary, in my case /Applications/MacPorts/MacVim.app/Contents/MacOS/MacVim. It seemed a little flaky in that it would only send the textarea to the buffer, and save edited content back, if MacVim wasn't open beforehand. That was okay because I use console Vim for everything else, and I can set MacVim to quit when the last window closes.
So, I was almost completely happy. The one down side was that I had been using Fluid to make a site-specific browser for GMail, which keeps my mail separate from my browser and seems to help keep Firefox's memory usage under control. But then, as I poked around MacVim's preferences I saw this.
I'm willing to risk it for the moment. Enabling the external editor means I can have Fluid + GMail + Vim. Using the It's All Text Firefox extension means I can use Vim to edit wiki pages or write blog posts, like I'm doing with this one right now. And all that means I'm pretty happy.
[Update: I'm _sure_ using MacVim as an external editor did work, but a day later edited text is no longer sent back to GMail. Sigh, perhaps I was imagining it. Now the closest I can get is cmd+A to select all the text in MacVim, close it, cmd+A to select all the text in GMail, then cmd+V to overwrite it with the edited text.]
- This is not your opportunity to say that it's even easier in emacs or textmate or notepad or whatever, because it's my blog and I like Vim, so there. ↩
- Later, frt told me that you can achieve this with :set guioptions+=mT. I didn't try it, but I may revisit Vimperator in the future. ↩
July 2nd, 2009 at 7:32pm
...GMail. http://pastoid.com/a3m+ Attachments http://twofishcreative.com/michael/blog/2009/07/02/fluid-gmail-vim
Published a few seconds ago
From xmp...
July 6th, 2009 at 8:28pm
You're a beautiful, beautiful man, Michael. Using vim to edit browser text areas has always been in my "too good to imagine" category. "It's All Text" works a treat with gvim under Ubuntu 8.04, for gmail and elsewhere (such as here!).
While I'm here, let me observe that I've tried a number of different vim emulators, but for me at least, my fingers are so habituated to specific vim commands that any imperfections or differences in the emulation leaves me floundering.
July 7th, 2009 at 10:45am
Glad I could be of assistance, though of course the real credit should go to the people I called out in the post.
I know what you mean about emulators, I've never had any joy at all. I would write a plugin for jsvi, but it would be simply for interest sake, and I wouldn't use it myself. Especially now that real Vim is at hand.
July 7th, 2009 at 10:57am
Well, I am typing this comment with MacVim so obviously I got something to work
(MacVim + It's All Text!). Not using Fluid.
Feels a bit weird, and when I edit the post (before submitting) it opens
further copies of MacVim...I now have 3 open.
July 8th, 2009 at 2:17pm
I set MacVim to close when the last window closes. That way, I shut the window, it sends the output back and quits. Works for me.
July 17th, 2009 at 9:19pm
...sing Vim rather than cutting-and-pasting all the time.
Update: Michael’s blog is back up now: here is his original post. This entry was posted on Thursday, July 16th, 2009 at 2:31 pm and is filed un...