~gpanders/dotfiles

b81dba3c3727dfb79314b9d4ba8abca06ad1e45f — Greg Anders 1 year, 11 months ago d0f2652
Automatically place cursor when writing mail messages
1 files changed, 18 insertions(+), 1 deletions(-)

M vim/.vim/after/ftplugin/mail.vim
M vim/.vim/after/ftplugin/mail.vim => vim/.vim/after/ftplugin/mail.vim +18 -1
@@ 10,4 10,21 @@ setlocal nolist

syntax clear TrailingWhitespace

let b:undo_ftplugin .= '|setl fo< wm< nu< dg< list<'
" See https://en.wikipedia.org/wiki/Posting_style
if !exists('g:mail_posting_style')
    let g:mail_posting_style = 'top'
endif

augroup mail
    autocmd!
    " 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
augroup END

let b:undo_ftplugin .= '|setl fo< wm< nu< dg< list<|au! mail * <buffer>'