blob: 3cef84f52832b13be884070e0555ecc0afec4a26 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
2" Language: Mail
Christian Brabandte978b452023-08-13 10:33:05 +02003" Maintainer: The Vim Project <https://github.com/vim/vim>
4" Last Change: 2023 Aug 10
5" Former Maintainer: Bram Moolenaar <Bram@vim.org>
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7" Only do this when not done yet for this buffer
8if exists("b:did_ftplugin")
9 finish
10endif
11let b:did_ftplugin = 1
12
Bram Moolenaar2df58b42012-11-28 18:21:11 +010013let b:undo_ftplugin = "setl modeline< tw< fo< comments<"
Bram Moolenaar071d4272004-06-13 20:20:40 +000014
Bram Moolenaar9964e462007-05-05 17:54:07 +000015" Don't use modelines in e-mail messages, avoid trojan horses and nasty
16" "jokes" (e.g., setting 'textwidth' to 5).
Bram Moolenaar071d4272004-06-13 20:20:40 +000017setlocal nomodeline
18
19" many people recommend keeping e-mail messages 72 chars wide
20if &tw == 0
21 setlocal tw=72
22endif
23
24" Set 'formatoptions' to break text lines and keep the comment leader ">".
25setlocal fo+=tcql
26
Bram Moolenaar2df58b42012-11-28 18:21:11 +010027" Add n:> to 'comments, in case it was removed elsewhere
28setlocal comments+=n:>
29
Bram Moolenaar113cb512021-11-07 20:27:04 +000030" .eml files are universally formatted with DOS line-endings, per RFC5322.
31" If the file was not DOS the it will be marked as changed, which is probably
32" a good thing.
33if expand('%:e') ==? 'eml'
34 let b:undo_ftplugin ..= " fileformat=" .. &fileformat
35 setlocal fileformat=dos
36endif
37
Bram Moolenaar5c736222010-01-06 20:54:52 +010038" Add mappings, unless the user doesn't want this.
Bram Moolenaar071d4272004-06-13 20:20:40 +000039if !exists("no_plugin_maps") && !exists("no_mail_maps")
40 " Quote text by inserting "> "
41 if !hasmapto('<Plug>MailQuote')
42 vmap <buffer> <LocalLeader>q <Plug>MailQuote
43 nmap <buffer> <LocalLeader>q <Plug>MailQuote
44 endif
45 vnoremap <buffer> <Plug>MailQuote :s/^/> /<CR>:noh<CR>``
46 nnoremap <buffer> <Plug>MailQuote :.,$s/^/> /<CR>:noh<CR>``
47endif