I'm currently using VIM to write emails for Mutt, it works great, but the word wrapping is driving me crazy. I currently set word wrapping when I call it from the muttrc file like so:
-c 'set fo+=aw' -c 'set tw=76'
This works perfectly, just what I was looking for. The problem is I also use headers in mutt so that when I'm writing an email the headers are first in my writer:
From: Name <me@me.com>
To:
Cc:
Bcc:
Subject:
Reply-To:
Message here
The problem is that VIM is now wrapping everything, including the headers. When I go up to the Subject line if I haven't input a CC and BCC is wraps like so:
Cc: Bcc: Subject:
So I'm looking for a way to stop it from wrapping anything before the first empty line of the editor? Any ideas?
First, you don't need to explicit set your setting in your .muttrc
, since Vim recognized mutt mails automatically and to set your settings for specifically writing mails with Vim, you simply create a file $HOME/.vim/ftplugin/mail.vim
(create directories, if they don't exists) and put your seetings there:
setl tw=76
setl fo+=aw
You need to, however explicitly enable filetype plugins in Vim, to enable this, e.g. your .vimrc
needs to contain filetype plugin on
or similar.
For making sure, that those formatoptions are only considered, when writing the body of the mail (as I have set edit_headers
on in mutt), I have written an autocommand, that specifically checks the region you are in and applies certain settings, if you are in the header or in a patch or in the signature region,...
I have written about this in more detail here. You might also be interested in the other settings at that page.