Friday, April 15, 2011

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?

Thanks.

From stackoverflow
  • Try this in your .muttrc:

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

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

    MTsoul : 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.
  • Shouldn't you be using a mutt configuration command? See the following links:

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

    autocmd FileType mail set spell
    
    MTsoul : How does Vim know that it's an email I am composing?
    sth : 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)

0 comments:

Post a Comment