Solved [Solved] Automagically adjusting Vim settings for e-mail

Surely there must be some vim experts out here. Normally I have textwidth set to 80. In other words, my ~/.vimrc contains
Code:
set textwidth=80
However, I'd prefer to use a slightly lower value (say 75) for e-mail. Can anyone think of a way to have vim automagically [sic] adjust textwidth when it's being invoked by Mutt?
 
Re: Automagically adjusting Vim settings for e-mail

Well, I can come up with two options and I'm not sure about first but most definitely about the second.

You can start vim by providing the file you want to open but also several startup options. So now I'm wondering if it would be possible to define the textwidth as an option when starting vim? I glimpsed vim(1) and I don't think this is possible, but I figured I'd mention it anyway.

But I think the best solution would be to create a second vimrc file, use it to configure all the options you might need when using vim as an e-mail editor (for example; you might want to add some support for GnuPG) and then configure mutt so that it starts vim with the -u option; that way you can provide a different vimrc file.
 
Re: Automagically adjusting Vim settings for e-mail

ShelLuser said:
So now I'm wondering if it would be possible to define the textwidth as an option when starting vim?
[snip]
But I think the best solution would be to create a second vimrc file, use it to configure all the options you might need when using vim as an e-mail editor (for example; you might want to add some support for GnuPG) and then configure mutt so that it starts vim with the -u option; that way you can provide a different vimrc file.
Thanks :beergrin Based on your suggestions I ended up doing the following: instead of creating an entire alternate ~/.vimrc file I created a small supplementary one that only contains a few overrides. Setting the editor in ~/.muttrc to vim -s /home/fonz/.vimrc.mail then takes care of the rest.

And I think it could be even better: somehow Mutt manages to set filetype to "mail". I'd have to examine the vimrc syntax a bit more, but I'm fairly confident that something along the lines of (pseudo-code)
Code:
if (filetype=mail)
   set textwidth=75
   do_more_mail_specific_stuff
endif
should be quite possible. To be continued...
 
Re: Automagically adjusting Vim settings for e-mail

After some further digging, this appears to be working quite nicely:
Code:
autocmd Filetype mail set textwidth=75
Perhaps this can help others to add filetype-specific settings to their vimrc :h
 
Back
Top