For those of us that send e-mail using the wonderful mutt and using vim as our editor, this is a neat trick I discovered yesterday.

If you are sending e-mail in format=flowed (and you should; for mutt, just add set text_flowed=yes to your .muttrc), your .vimrc file for mail will look something like this:

setl tw=72
setl fo=watqc
setl nojs
setl nosmartindent

This makes the editor hard-wrap your text in a way that lets the e-mail client at the other side render it as it pleases (so, for instance, no more weirdly broken lines when someone reads your e-mail on a mobile device). The way this works is by leaving a trailing space where two lines can be merged together, and ending a line immediately after a non-blank character where a real hard break should occur.

However, after some e-mail editing we may leave some blanks at the end of lines that shouldn't be there, or there are some missing that should be included, if we are copying and pasting text, for instance. It would be good to visualize the trailing spaces for each line so we can make sure the format will be correct.

It turns out one only needs to add this line to our vim config:

" Mark trailing spaces, so we know we are doing flowed format right
match ErrorMsg '\s\+$'