Write your emails in markdown with vim

Posted by Fabrice on Monday, April 22, 2019 Updated on Saturday, October 14, 2023 Translation: fr

If you are like me and you don't like to spend time using WYSIWYG tools to format your texts, you may be interested in this.

However, I'm using thunderbird to handle my emails. As you may have noticed, you can copy paste from some web page and paste it in thunderbird (which can cause invisible break in the styling). Exploiting this, one can directly export html into the clipboard to past it in thunderbird.

The command is as simple as:

pandoc -t html5 -s <file> | xclip -selection clipboard

Therefore, adding:

map <your map> :w !pandoc -t html5 -s \| xclip -selection clipboard<cr>

or a more modern version using lua and wayland:

vim.keymap.set('n', <your map>, ':w !pandoc -t html5 -s | wl-copy<CR><CR>', { noremap = true, silent = true })

in your vim ftplugin/pandoc.vim configuration file allows you to copy directly the output of pandoc on you opened buffer into your clipboard and thus past it directly into thunderbird. Of course, you can customize this command line as you want. For instance my base-header-level is 4, as I think that first-level titles are a bit too much for emails.
You can even use some simple css rules in a separated style sheet along with the --self-contained option of pandoc to be able to do basic general formating (for a newsletter for instance).

Note: I'm using the vim-pandoc and the vim-pandoc-syntax plugins for vim.

Here follows a direct usecase of this: a GDPR death letter inspired from aeris' one.

Dear Sir or Madam,

My personal data, such as my e-mail address, are protected under the
GDPR law since May 2016:\

As per article 3, all GDPR applies to you as I am an EU citizen, even
if you are outside EU:\

As per article 15, I request you to provide me all personal data you
have about myself, the purpose of the processing, why and **how** you
collect them, if you share my data with others people or countries,
and all other informations that are mentioned in the following:\

As per article 7, I request you to **prove** my **explicit** and
**positive** consent fr my personnal data to be collected and

As per article 17, I also request all my personal data to be erased
from your databases (including backups), with a proof of erasure,
**but only once you provided me with all the aforementioned

As per article 12, these requests have to be fulfilled within **a
month** from Today (April 4th 2019). Should this not be the case,
I will open a case with EU regulator:\

As per article 19, I have the same request to **all your partners** to
whom my personal data have been transfered to. These have to be
accompanied by an attestation of erasure from these partners as

This e-mail is signed under the GPG key
that also appears in the above website, which suffices to prove my
identity as the rightful owner of these personal data.

If you require further information to fulfill my requests, feel free
to contact me on this e-mail address.

Sincerely yours,  

tags: emails, pandoc, Vim