From 8d91ebd93c56031345ebf6ada80483e5b0979724 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 23 May 2019 11:21:56 +1200 Subject: Normalise quoting in mail --- vim/after/ftplugin/mail.vim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'vim') diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index 81e2e560..649c87e1 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -20,6 +20,27 @@ if line('.') == 1 && col('.') == 1 endif +" Normalise quoting +for lnum in range(1, line('$')) + + " Get current line + let line = getline(lnum) + + " Get the leading quote string, if any; stop if there isn't one + let quote = matchstr(line, '^[> \t]\+') + if strlen(quote) == 0 + return + endif + + " Normalise the quote with no intermediate and one trailing space + let quote = substitute(quote, '[^>]', '', 'g').' ' + + " Re-set the line + let line = substitute(line, '^[> \t]\+', quote, '') + call setline(lnum, line) + +endfor + " Add a space to the end of wrapped lines for format-flowed mail setlocal formatoptions+=w let b:undo_ftplugin .= '|setlocal formatoptions<' -- cgit v1.2.3