" Extra configuration for mail messages if &filetype !=# 'mail' || &compatible || v:version < 700 finish endif " If something hasn't already moved the cursor, we'll move to an optimal point " to start writing if line('.') == 1 && col('.') == 1 " Start by trying to move to the first quoted line; this may fail if there's " no quote, which is fine call search('\m^>', 'c') " Check this line to see if it's a generic hello-name greeting that we can " just strip out; delete any following lines too, if they're blank if getline('.') =~? '^>\s*\%($' delete endwhile endif " Now move to the first quoted or unquoted blank line call search('\m^>\=$', 'c') endif " Add a space to the end of wrapped lines for format-flowed mail setlocal formatoptions+=w let b:undo_ftplugin .= '|setlocal formatoptions<' " Define what constitutes a 'blank line' for the squeeze_repeat_blanks.vim " plugin, if loaded, to include leading quotes and spaces if exists('g:loaded_squeeze_repeat_blanks') let b:squeeze_repeat_blanks_blank = '^[ >]*$' let b:undo_ftplugin .= '|unlet b:squeeze_repeat_blanks_blank' endif " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_mail_maps') finish endif " Clear away the quoting maps that the stock mail.vim sets; they work fine, " but we have nicer ones to define shortly nunmap q vunmap q nunmap MailQuote vunmap MailQuote " Flag messages as important/unimportant nnoremap h \ :call mail#FlagImportant() let b:undo_ftplugin .= '|nunmap h' nnoremap l \ :call mail#FlagUnimportant() let b:undo_ftplugin .= '|nunmap l' " Quote operator nnoremap q \ quote#Quote() nnoremap qq \ quote#Quote().'_' xnoremap q \ quote#Quote() let b:undo_ftplugin .= '|nunmap q' \ . '|nunmap qq' \ . '|xunmap q' " Quote operator with reformatting nnoremap Q \ quote#QuoteReformat() nnoremap QQ \ quote#QuoteReformat().'_' xnoremap Q \ quote#QuoteReformat() let b:undo_ftplugin .= '|nunmap Q' \ . '|nunmap QQ' \ . '|xunmap Q' " Maps using autoloaded function for quoted paragraph movement nnoremap [ \ :call mail#NewBlank(v:count1, 1, 0) nnoremap ] \ :call mail#NewBlank(v:count1, 0, 0) onoremap [ \ :call mail#NewBlank(v:count1, 1, 0) onoremap ] \ :call mail#NewBlank(v:count1, 0, 0) xnoremap [ \ :call mail#NewBlank(v:count1, 1, 1) xnoremap ] \ :call mail#NewBlank(v:count1, 0, 1) let b:undo_ftplugin .= '|nunmap [' \ . '|nunmap ]' \ . '|ounmap [' \ . '|ounmap ]' \ . '|xunmap [' \ . '|xunmap ]'