diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-23 11:21:56 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-23 11:21:56 +1200 |
commit | 8d91ebd93c56031345ebf6ada80483e5b0979724 (patch) | |
tree | 4e1ffdfc8ea5b008d6540fb27c5437e25ddca0ad /vim/after/ftplugin/mail.vim | |
parent | Strip trailing blanks after greeting (diff) | |
download | dotfiles-8d91ebd93c56031345ebf6ada80483e5b0979724.tar.gz dotfiles-8d91ebd93c56031345ebf6ada80483e5b0979724.zip |
Normalise quoting in mail
Diffstat (limited to 'vim/after/ftplugin/mail.vim')
-rw-r--r-- | vim/after/ftplugin/mail.vim | 21 |
1 files changed, 21 insertions, 0 deletions
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<' |