mail.vim 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. " Vim filetype plugin file
  2. " Language: Mail
  3. " Maintainer: Bram Moolenaar <Bram@vim.org>
  4. " Last Change: 2021 Oct 23
  5. " Only do this when not done yet for this buffer
  6. if exists("b:did_ftplugin")
  7. finish
  8. endif
  9. let b:did_ftplugin = 1
  10. let b:undo_ftplugin = "setl modeline< tw< fo< comments<"
  11. " Don't use modelines in e-mail messages, avoid trojan horses and nasty
  12. " "jokes" (e.g., setting 'textwidth' to 5).
  13. setlocal nomodeline
  14. " many people recommend keeping e-mail messages 72 chars wide
  15. if &tw == 0
  16. setlocal tw=72
  17. endif
  18. " Set 'formatoptions' to break text lines and keep the comment leader ">".
  19. setlocal fo+=tcql
  20. " Add n:> to 'comments, in case it was removed elsewhere
  21. setlocal comments+=n:>
  22. " .eml files are universally formatted with DOS line-endings, per RFC5322.
  23. " If the file was not DOS the it will be marked as changed, which is probably
  24. " a good thing.
  25. if expand('%:e') ==? 'eml'
  26. let b:undo_ftplugin ..= " fileformat=" .. &fileformat
  27. setlocal fileformat=dos
  28. endif
  29. " Add mappings, unless the user doesn't want this.
  30. if !exists("no_plugin_maps") && !exists("no_mail_maps")
  31. " Quote text by inserting "> "
  32. if !hasmapto('<Plug>MailQuote')
  33. vmap <buffer> <LocalLeader>q <Plug>MailQuote
  34. nmap <buffer> <LocalLeader>q <Plug>MailQuote
  35. endif
  36. vnoremap <buffer> <Plug>MailQuote :s/^/> /<CR>:noh<CR>``
  37. nnoremap <buffer> <Plug>MailQuote :.,$s/^/> /<CR>:noh<CR>``
  38. endif