~gpanders/dotfiles

ref: 925a7bc911c0f7ba01bc27b3643824324e294ef7 dotfiles/vim/.vim/after/ftplugin/mail.vim -rw-r--r-- 1019 bytes
925a7bc9Greg Anders Enable spell checking in mail files 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
" mail filetype configuration
" Author: Greg Anders
" Date: 2018-12-02

setlocal formatoptions+=wa
setlocal wrapmargin=0
setlocal nonumber
setlocal nolist
setlocal spell
let b:undo_ftplugin .= '|setl fo< wm< nu< list< spell<'

let b:highlight_trailing_whitespace = 0
let b:undo_ftplugin .= '|unlet! b:highlight_trailing_whitespace'

" See https://en.wikipedia.org/wiki/Posting_style
if !exists('g:mail_posting_style')
    let g:mail_posting_style = 'top'
endif

augroup mail
    autocmd!
    if !&readonly && &modifiable
        " Place cursor in writing position and start insert mode
        if g:mail_posting_style ==# 'top'
            autocmd BufWinEnter <buffer> exe "normal! }2o\<Esc>k" | startinsert
        elseif g:mail_posting_style ==# 'bottom'
            autocmd BufWinEnter <buffer> exe "normal! G2o\<Esc>" | startinsert
        else
            echohl Error | echom 'Unknown value for g:mail_posting_style' | echohl None
        endif
    endif
augroup END
let b:undo_ftplugin .= '|au! mail * <buffer>'