mail.vim 1.6 KB

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