Main image
23rd January
2009

How to set up an external editor for Thunderbird under Mac OS X.

written by Mark Wheadon

If you use Thunderbird on your Mac then you may wish to use an external editor to compose your email rather than the internal one. In my case I’m a long-time vi user so I find it convenient to drop into vi at times, when the editing starts to get non-trivial.

There’s a plugin for Thunderbird which allows you to do this, but setting it up can be tricky, so I thought I’d document it here.

Install vi

First — assuming you’re a vi user — you need to download MacVim (one of several vis for the Mac, but one I know looks the part and works well), and install it.

Add a small script

Next, you need a small shell script to start up MacVim from Thunderbird (you can’t just point the Thunderbird plugin at MacVim.app — it doesn’t work like that).

Start up a Terminal window (cmd+space terminal <return>), and create the script:

cd /Applications
vi dovim

and here’s the script:

#!/bin/sh
exec open -W -a macvim "$@"

The -W ensures that open waits for MacVim to finish, as otherwise Thunderbird tries to read the file left behind by MacVim before MacVim has finished — which is not good :-)

Now ensure that the script is executable

chmod +x dovim

Install the external editor plugin for Thunderbird

Next, download and install the external editor plugin for Thunderbird from here.

Note:  If you’re using Safari then you may hit a problem at this point. The download is supposed to be a single .xpi file and indeed, that’s what’s offered by the download link. Unfortunately Safari notices that’s it’s really a zip file, and so renames it to <file>.xpi.zip You need to rename the file back — strip the .zip off the end of the file name.

Apart from the above caveat, install the plugin in the usual way, then configure it — not to use MacVim itself, but to use the dovim script you placed in /Applications and you’re almost there.

Finally, tweak MacVim’s settings

Start up MacVim and change its settings so that the application quits when the last window quits, as otherwise Thunderbird won’t wake up until you close the MacVim application completely:

Change MacVim setting

and that should be it, you can now drop into vi from within Thunderbird‘s email editor.

No related posts.

3 Comments

  1. Ben
    20/08/2009

    Thanks for the tip, however this doesn’t work for me for a very good reason! I frequently have multiple instances of macvim running with 5-10 tabs open in each instance. I also write emails all day long.

    This method requires me to close all of my macvim instances just to send an email! This is much less convenient than simply composing in macvim, and then pasting into TB.

    Any ideas around this?

  2. Mark Wheadon
    21/08/2009

    Hi Ben — I can see that’s a problem for you and others who use macvim a fair bit.

    Here’s a work-around. It’s dirty (very dirty) but I think it’ll prove reliable. Replace your dovim script with the following — best use cut and paste as there’s some subtle quoting in there (and best hold your nose whilst doing so :-) :

    Cheers,

    Mark


    #!/bin/sh

    open -a macvim "$@"
    sleep 3 # be sure Vim has started
    pid=`/bin/ps -A | awk '/\/Vim/ && $NF == "'"/private$@"'" {print $1}'`
    while kill -0 $pid 2> /dev/null; do
    sleep 1
    done
    exit 0

    Note that the code that starts with pid= and ends with print $1 is all one long line (this should happen anyway if you cut and paste).

  3. Francisco Beron-Vera
    25/01/2010

    Hi Mark,

    Your solution works provided that the “Launch Vim processes in a login shell” option is not selected. But Vim-Latex, which I use frequently, needs that option selected in order to work. Any idea as of how to get it to work with this option selected?

    Thank you in advance.

    Best regards,
    Francisco

Leave a Reply