Using Vim as Thunderbird’s External Editor on Linux
Thunderbird’s built-in compose window is functional but limited. Using Vim as an external editor gives you the full power of modal editing and your customizations for email composition.
Prerequisites
You need Thunderbird with the External Editor extension installed. As of 2026, this extension continues to work with current Thunderbird versions. Install it from the Thunderbird add-ons repository.
Setting up the external editor
You have two main approaches: use a graphical Vim variant, or invoke Vim in a terminal.
Option 1: Using gvim (simpler)
If you have gvim installed, configuration is straightforward. In External Editor’s preferences, set the text editor command to:
gvim -f
The -f flag keeps gvim in the foreground, blocking Thunderbird until you save and exit.
Option 2: Using Vim in a terminal (recommended)
If you prefer the terminal version, you’ll need a wrapper script since Vim alone won’t work reliably with Thunderbird’s IPC mechanism.
Create a script called callvim in a directory on your PATH (e.g., ~/bin/):
#!/bin/bash
# Wrapper to launch Vim in a terminal for Thunderbird's External Editor
# Works with xterm, but modern terminals like Alacritty or foot also work
if command -v xterm &> /dev/null; then
xterm -e vim "$@"
elif command -v alacritty &> /dev/null; then
alacritty -e vim "$@"
else
# Fallback - adjust based on your system's available terminals
urxvt -e vim "$@"
fi
Make it executable:
chmod +x ~/bin/callvim
Then in External Editor’s preferences, set the text editor command to:
callvim
The script uses xterm by default (widely available), but you can replace it with alacritty, foot, or your preferred terminal if it’s faster or better integrated with your desktop.
Using Vim in Thunderbird
Once configured, press Ctrl+E while composing a new message or replying to open your external editor. Edit the message in Vim, save it (:wq), and exit. Thunderbird immediately updates the compose window with your changes.
Optimizing Vim for email
Add email-specific configuration to your ~/.vimrc to tailor Vim for message composition:
augroup email
autocmd!
autocmd FileType mail call SetupMailOptions()
augroup END
function! SetupMailOptions()
setlocal textwidth=72
setlocal spell spelllang=en
setlocal wrap
setlocal linebreak
setlocal noautoindent
setlocal nocindent
" Auto-format quoted text (lines starting with >)
setlocal formatoptions=aw
" Abbreviations for common phrases
iabbrev <buffer> gd Good day!
iabbrev <buffer> regards Best regards,
iabbrev <buffer> thx Thank you!
endfunction
Key settings explained:
textwidth=72: Standard email width for better readability and compatibility with quoted textspell spelllang=en: Enable spell checkingwrapandlinebreak: Wrap long lines without breaking wordsformatoptions=aw: Auto-format paragraphs and preserve existing formattingiabbrev <buffer>: Buffer-local abbreviations that expand as you type
Advanced customization
You can detect Thunderbird-specific mail files (typically temporary files) and apply settings automatically:
" Detect Thunderbird's temporary mail files
autocmd BufRead,BufNewFile /tmp/nscopy*,/tmp/mutt* setfiletype mail
For signature handling, add this to skip signatures during spell checking:
function! SetupMailOptions()
" ... existing settings ...
" Skip lines starting with -- (signature delimiter)
setlocal spellcapcheck=[.?!]\\_[\\]\\ ]\\+
syntax match mailSignature /^-- $/ nextgroup=mailSignatureBody
syntax match mailSignatureBody /.*/ contained
highlight mailSignatureBody ctermfg=gray
endfunction
Troubleshooting
Editor doesn’t open: Verify the command path is correct by running it directly in a terminal with a test file.
Thunderbird hangs: Make sure your wrapper script blocks until Vim exits. Avoid background processes or detached terminals.
Character encoding issues: Thunderbird defaults to UTF-8 for modern email. Vim’s default settings handle this, but if you see garbled text, check your locale and Vim’s fileencoding setting.
Terminal doesn’t appear: On some X11 systems, use gnome-terminal -- vim "$@" instead of xterm, or switch to a lightweight terminal like Alacritty for better startup time.

Update: gnome-terminal (3.8.4) in Gnome 3 does not work with the `callvim` script. Updated to use `xterm`.
Hi Zhiqiang
Thank you for posting this.
It’s rather old, but I just tried it with urxvt and it works flawlessly.
Have a good day.
cee
Hi cee,
Very glad to know it help.
BTW: first time to know urxvt.
yeah, urxvt (the rxvt family), rxvt-unicode-256color are great, unicode terminals that can even be perl scripted.
anyway, the command for urxvt is, or can be, :
urxvt -g 80×26 -title “vim icedove email” -e vim -f
Don’t append a $* or anything, and the title is optional. The title just means that your window manager can identify the window if you wish it to be positioned or in anyway managed by your ‘window’ ‘manager’.
I needed to add ‘syntax on’ to FT_mail().