mail.vim 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. " Vim filetype plugin file
  2. " Language: Mail
  3. " Maintainer: The Vim Project <https://github.com/vim/vim>
  4. " Last Change: 2023 Aug 10
  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<"
  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. " Add n:> to 'comments, in case it was removed elsewhere
  22. setlocal comments+=n:>
  23. " .eml files are universally formatted with DOS line-endings, per RFC5322.
  24. " If the file was not DOS the it will be marked as changed, which is probably
  25. " a good thing.
  26. if expand('%:e') ==? 'eml'
  27. let b:undo_ftplugin ..= " fileformat=" .. &fileformat
  28. setlocal fileformat=dos
  29. endif
  30. " Add mappings, unless the user doesn't want this.
  31. if !exists("no_plugin_maps") && !exists("no_mail_maps")
  32. " Quote text by inserting "> "
  33. if !hasmapto('<Plug>MailQuote')
  34. vmap <buffer> <LocalLeader>q <Plug>MailQuote
  35. nmap <buffer> <LocalLeader>q <Plug>MailQuote
  36. endif
  37. vnoremap <buffer> <Plug>MailQuote :s/^/> /<CR>:noh<CR>``
  38. nnoremap <buffer> <Plug>MailQuote :.,$s/^/> /<CR>:noh<CR>``
  39. endif