From 2e5f2b861b077193405684fe3c74de20f849ad5f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 13 Jul 2018 23:53:55 +1200 Subject: Replace mail.vim quoting mappings --- vim/after/ftplugin/mail.vim | 16 +++++++++++++++- vim/autoload/mail.vim | 11 +++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 vim/autoload/mail.vim (limited to 'vim') diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index fa1b9443..d22ec142 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -1,5 +1,5 @@ " Extra configuration for mail messages -if &filetype !=# 'mail' || v:version < 700 +if &filetype !=# 'mail' || &compatible || v:version < 700 finish endif @@ -13,3 +13,17 @@ endif " Add a space to the end of wrapped lines for format-flowed mail setlocal formatoptions+=w let b:undo_ftplugin .= '|setlocal formatoptions<' + +" Stop here if the user doesn't want ftplugin mappings +if exists('g:no_plugin_maps') || exists('g:no_mail_maps') + finish +endif + +" The quote mapping in the stock plugin is a good idea, but I prefer it to +" work as a motion rather than quoting to the end of the buffer +nnoremap q mail#Quote() +nnoremap qq mail#Quote().'_' +xnoremap q mail#Quote() +let b:undo_ftplugin .= '|nunmap q' + \ . '|nunmap qq' + \ . '|xunmap q' diff --git a/vim/autoload/mail.vim b/vim/autoload/mail.vim new file mode 100644 index 00000000..4c21ae38 --- /dev/null +++ b/vim/autoload/mail.vim @@ -0,0 +1,11 @@ +" Quote lines in mail messages +function! mail#Quote() abort + set operatorfunc=mail#QuoteOpfunc + return 'g@' +endfunction +function! mail#QuoteOpfunc(type) abort + for l:li in range(line('''['), line(''']')) + let l:line = getline(l:li) + call setline(l:li, '>'.l:line) + endfor +endfunction -- cgit v1.2.3