The format=flowed
convention, specified in RFC 3676 is a way of
formatting text-based messages so that they can be displayed nicely
independently of the screen’s (or terminal’s) width. The core of the
convention, roughly, is to distinguish soft line breaks, which the
displaying software is free to re-arrange (and which are marked by a trailing
space character), from hard line breaks, which are meant to always be
honored.
See the above-mentioned RFC for more details on the format. The point of
this short note is to explain how to configure the Neomutt mail client, along with the Vim editor, to use the
format=flowed
convention.
Neomutt really needs only one configuration tweak in order to use
format=flowed
. Simply add the following line to the
neomutt.rc
configuration file:
set text_flowed
This will instruct Neomutt to add the format=flowed
parameter
to the Content-Type
header of newly generated mails.
Add the following line to the ~/.vim/filetype.vim
file:
au BufNewFile,BufRead neomutt-* setf mail
This will lead Vim to use the mail filetype anytime it edits a
file whose name starts with neomutt-
, which will happen when the
editor is fired from Neomutt to compose a message.
Then create a ~/.vim/after/ftplugin/mail.vim
file, with the
following contents:
setl tw=72 setl fo=awq setl comments+=nb:> match ErrorMsg '\s\+$'
The first line sets the maximal line length to 72 characters. The second
enables automatic formatting of paragraphs, with a trailing white space
indicating a paragraph continues in the next line. The third line specifies
that lines starting with >
are “comments” (so that quotes
within a mail can be displayed differently from the rest of the message).
Finally, the last line allows to highlight the trailing space at the end of broken lines, to provide a visual distinction between “soft” and “hard” line breaks.