Main image
23rd January

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 — 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:

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> 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.


  1. Ben

    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

    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 :-):




    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
    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

    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,

  4. Tom K

    Thanks for this post; it got me on the right track.

    I would suggest, though, that it is easier to not use either the open command in the shell script nor a shell script at all. You can evoke MacVim directly from the command line. Here is what I am using in the text editor field.

    /Applications/ -g -f ‘+/^-=-/+1’

    The open command was causing more then a 30 second delay for me when I evoked the shell script. The direct call to the executable takes about 1 second.

    The arguments are the same as from a real unix environment: -g to use the GUI, and -f to not fork into the background (the same reason for adding the -W in the shell script). The last argument ‘+/^-=-/+1’ starts me at the first blank line after the headers.

    Lastly, if the macvim app name has spaces in it, you should rename it so it does not have spaces. Spaces in the name makes it harder for the unix command line to find the executable.

  5. Richard

    ## Solution to OS X / Thunderbird slow load times ##

    – Download MacVim :
    : Move everything to the directory to /Applications/

    – Download Thunderbird External Editor

    – In Thunderbird install `External Editor`

    – Edit the preferences to `External Editor`
    Editor = /Applications/mvim –servername email –remote-wait

    – Using Automator, create a new `Workflow`

    : Select `Run Shell Script` : For a script enter the two lines :
    1 open /Applications/mvim –servername email &
    2 open /Applications/
    : Save -> File Format : Application :

    You now have a built application that’ll run Thunderbird, with a background
    VIM process.

    – CMD + E to load a VIM instance

Leave a Reply