aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-05-23 11:21:56 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-05-23 11:21:56 +1200
commit8d91ebd93c56031345ebf6ada80483e5b0979724 (patch)
tree4e1ffdfc8ea5b008d6540fb27c5437e25ddca0ad /vim
parent60703c3aa0b624cbc2b799d679a11118dca18e7d (diff)
downloaddotfiles-8d91ebd93c56031345ebf6ada80483e5b0979724.tar.gz
Normalise quoting in mail
Diffstat (limited to 'vim')
-rw-r--r--vim/after/ftplugin/mail.vim21
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<'