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