" Don't append spaces after quote chars, for strict compliance with " format=flowed let b:quote_space = 0 " 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') " Delete quoted blank lines or quoted greetings until we get to something " with substance. Yes, I like Perl, how could you tell? while getline('.') =~? '^> *' \ . '\%(' \ . '\%(' \ . 'g[''\u2019]\=day' \ . '\|\%(good \)\=\%(morning\|afternoon\|evening\)' \ . '\|h[eu]\%(ll\|rr\)o\+' \ . '\|hey\+' \ . '\|hi\+' \ . '\|sup' \ . '\|what[''\u2019]\=s up' \ . '\|yo' \ . '\)' \ . '[[:punct:] ]*' \ . '\%(' \ . '\a\+' \ . '[[:punct:] ]*' \ . '\)\=' \ . '\)\=$' delete endwhile " Now move to the first quoted or unquoted blank line call search('\m^>\= *$', 'c') endif " Normalise quoting let body = 0 for lnum in range(1, line('$')) " Get current line let line = getline(lnum) " Skip lines until we hit a blank line, meaning body text let body = body || !strlen(line) if !body continue endif " Get the leading quote string, if any; skip if there isn't one let quote = matchstr(line, '^>[> ]*') if strlen(quote) == 0 continue endif " Normalise the quote with no spaces let quote = substitute(quote, '[^>]', '', 'g') " Re-set the line let line = substitute(line, '^[> ]\+', 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<' " Mail-specific handling for custom vim-squeeze-repeat-blanks plugin if exists('loaded_squeeze_repeat_blanks') " Set the blank line pattern let b:squeeze_repeat_blanks_blank = '^[ >]*$' let b:undo_ftplugin .= '|unlet b:squeeze_repeat_blanks_blank' " If there is anything quoted in this message (i.e. it looks like a reply), " squeeze blanks, but don't report lines deleted if search('\m^>', 'cnw') silent SqueezeRepeatBlanks endif endif " Spellcheck documents we're actually editing (not just viewing) if &modifiable && !&readonly setlocal spell let b:undo_ftplugin .= '|setlocal spell<' endif " Stop here if the user doesn't want ftplugin mappings if exists('no_plugin_maps') || exists('no_mail_maps') finish endif " 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() xnoremap q \ quote#Quote() let b:undo_ftplugin .= '|nunmap q' \ . '|xunmap q' " Quote operator with reformatting nnoremap Q \ quote#QuoteReformat() xnoremap Q \ quote#QuoteReformat() let b:undo_ftplugin .= '|nunmap Q' \ . '|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 ]'