" bounce verbosely between autoformat and not let autoformat_mode = 0 function! ToggleAutoformat() if g:autoformat_mode == 0 setlocal fo+=an let g:autoformat_mode = 1 echo "autoformat mode on" else setlocal fo-=an let g:autoformat_mode = 0 echo "autoformat mode OFF" endif return endfunction if has("autocmd") autocmd FileType mail nmap f :ToggleAutoformat() endif