add autofmt toggle

Mon, 01 Aug 2016 15:23:12 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 01 Aug 2016 15:23:12 -0400
changeset 361
7ab7173fb61f
parent 360
951e2cf18190
child 362
7c5b0e94b399

add autofmt toggle

.vim/ftplugin/mail.vim file | annotate | diff | comparison | revisions
--- a/.vim/ftplugin/mail.vim
+++ b/.vim/ftplugin/mail.vim
@@ -1,6 +1,7 @@
 
-function JumpAndInsert()
+function! JumpAndInsert()
   if line('$') > 1
+    :0
     :/^$/
     :normal 2] 
     :+1
@@ -8,11 +9,24 @@ function JumpAndInsert()
   endif
 endfunction
 
+function! AutoFmtToggle()
+  if &formatoptions =~ 'a'
+    set fo-=a
+    echo '-a'
+  else
+    set fo+=a
+    echo '+a'
+  endif
+endfunction
+
 augroup mail_filetype
   autocmd!
-  autocmd VimEnter /tmp/mutt* :call JumpAndInsert()
+  autocmd BufReadPost mutt-* :call JumpAndInsert()
 augroup END
 
 setl textwidth=72
 setl formatoptions=aw
 setl spell
+
+map <silent> <leader>a :call AutoFmtToggle()<CR>
+imap <silent> <leader>a :call AutoFmtToggle()<CR>

mercurial