On Jan 05, 2019 at 17:02, Ed Blackman wrote:
On Wed, Dec 19, 2018 at 11:10:02AM -0800, Will Yardley wrote:
Even when people are using the right options in vim and doing everything else right, it seems very fragile and prone to generating invalid flowed emails.

I stopped using format=flowed because not much besides Mutt supports it, and particularly not GMail and Outlook.

That's interesting. I've been using format=flowed for ages now, never really checked how it looked in other MUA. It worked in Mutt and I was happy with that. Never got any complaints.

But when I did use it, I configured vim to use syntax highlighting to add an underline highlight to the trailing space at the end of a line that format=flowed uses to know that it's a line that should be flowed.

It was subtle enough to not bother me when composing (since the sentence
your composing has a "trailing space" before you start the next word),
but blatent enough to see when I'm looking over the message before
saving.

In ~/.vim/after/syntax/mail.vim, I have:

" color trailing spaces to easily see where format=flowed lines will wrap and
" not wrap
syntax match lineEndWrap / $/
hi WrapLines term=bold,underline cterm=bold,underline gui=bold,underline

if &background == "dark"
 hi WrapLines ctermfg=White ctermbg=Black guifg=Black guibg=White
else
 hi WrapLines ctermfg=Black ctermbg=White guifg=Black guibg=White
endif

hi def link lineEndWrap WrapLines

Vim has built in support for highlighting trailing spaces using `listchars`.

I have this in my vimrc. It's also helpful to highlight them in other documents, but I don't want to be distracted while in INSERT mode.

set listchars+=trail:·
augroup trailing
   au!
   au InsertEnter * :set listchars-=trail:·
   au InsertLeave * :set listchars+=trail:·
augroup END

In addition, I also do some auto formatting for every email I compose, in `ftplugin/mail.vim`, I have:

setlocal formatoptions+=awt " auto-format

" pad '>' with a single space
keeppatterns keepjumps %s/>\ze\([^> ]\|$\)/> /e
" remove spaces between '>'
keeppatterns keepjumps %s/> >/>>/ge
" remove trailing spaces in header
keeppatterns keepjumps 1;/^$/s/ *$//e

Attachment: signature.asc
Description: PGP signature

Reply via email to