Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to :set spell in Vim only for emails?

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?

like image 717
Oliver Zheng Avatar asked Mar 27 '09 20:03

Oliver Zheng


People also ask

How do I set spell check in Vim?

By default, spell check will be off. If you want to turn it on, run setlocal spell in the Vim command line (if you want spell check to always be on, add set spell to your . vimrc). After turning spell check on, misspelled words will now be highlighted.

How do you add words to Vim dictionary?

We can teach Vim to recognize words with the zg command (zgⓘ), which adds the word under the cursor to a spell file. Vim also provides a complementary zw command, which marks the word under the cursor as a misspelled word.


2 Answers

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

autocmd FileType mail set spell
like image 139
sth Avatar answered Oct 16 '22 19:10

sth


Try this in your .muttrc:

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

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

like image 30
brian-brazil Avatar answered Oct 16 '22 17:10

brian-brazil