6

Google is not being very helpful here. I'd like to compose emails with :set spell on, but for all other files, :set spell should be off. I am using mutt, and Vim as the editor for composing emails.

In fact, I'm curious, how does Vim know that it's an email I'm composing? Is there a command-line parameter of the type of file being edited? How does mutt know what to pass in?

Raphael Ahrens
  • 953
  • 15
  • 29
Oliver Zheng
  • 7,831
  • 8
  • 53
  • 59

4 Answers4

19

You can use an autocmd in your ~/.vimrc that gets triggered by the detected file type:

autocmd FileType mail set spell
sth
  • 222,467
  • 53
  • 283
  • 367
  • How does Vim know that it's an email I am composing? – Oliver Zheng Mar 29 '09 at 20:47
  • 5
    Vim knows mutts naming scheme for temporary files. If a file fits that pattern, vim treats it as a mail. (For details look into your filetype.vim that is probably located somewhere in /usr/share/vim) – sth Mar 29 '09 at 22:21
  • Exactly! I would prefer this method over the "set editor" line, since it allows you also to set the spelllang and other options, in a more readable manner... – osti Apr 24 '11 at 08:40
  • Exactly, I use this setup to set things like textwidth, nonu, nocursor, etc. – Rick Apr 03 '12 at 11:38
8

Try this in your .muttrc:

set editor = "/usr/bin/vim -c':set spell'"

You can find the correct path to vim with "which vim".

brian-brazil
  • 31,678
  • 6
  • 93
  • 86
  • 1
    Perfect thanks. It doesn't seem like mutt requires the full path to vim, which is great if I want to use the same muttrc file across platforms. – Oliver Zheng Mar 27 '09 at 20:51
0

Shouldn't you be using a mutt configuration command? See the following links:

dirkgently
  • 108,024
  • 16
  • 131
  • 187
0

Add the following into your ~/.vimrc:

set spelllang=en_gb,fr
au BufRead,BufNewFile *mutt* set filetype=mail
autocmd FileType mail set spell

And it should work fine. You can (should?) change the spelllang to reflect any languages that your routinely use.

Sardathrion - against SE abuse
  • 17,269
  • 27
  • 101
  • 156