How to :set spell in Vim only for emails?
Asked Answered
M

4

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?

Mush answered 27/3, 2009 at 20:32 Comment(0)
B
19

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

autocmd FileType mail set spell
Bencher answered 27/3, 2009 at 21:1 Comment(4)
How does Vim know that it's an email I am composing?Mush
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)Bencher
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...Searchlight
Exactly, I use this setup to set things like textwidth, nonu, nocursor, etc.Farrel
E
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".

Euhemerize answered 27/3, 2009 at 20:41 Comment(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.Mush
C
0

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

Confirmatory answered 27/3, 2009 at 20:42 Comment(0)
A
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.

Augmentative answered 3/4, 2012 at 6:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.