Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Emacs has something called message-mode (type M-x message-mail) that can be used to compose emails. This mode helps one to automatically wrap text to 72 columns .. keeping quoted marks properly.

Is there such a thing for VIM?

I am switching from Emacs to VIM and message-mode is the only thing that needs to be migrated.

NOTE: I don't want VIM to send emails; for that .. I use some other client. I only want to edit emails in VIM.

share|improve this question

3 Answers 3

up vote 5 down vote accepted

Yes. Vim implements message-mode using filetypes.

Vim should be able to autodetect that you're editing a mail message. It should automatically set the filetype to mail. You can check this by displaying the current value of filetype by typing (in command mode) ...

:set filetype

You can also force Vim to use a particular filetype. In command mode, type ...

:set filetype=mail

to force Vim to set the default editing preferences for mail messages.

You can read more about filetypes in the Vim help system.

:help filetype
share|improve this answer
    
html documentation at vim.org: vim.org/htmldoc/filetype.html (may not be up-to-date for v7.x) –  quack quixote Oct 21 '09 at 12:07
    
But it does not automatically wrap long lines to fit the 72 cols. –  Sridhar Ratnakumar Oct 21 '09 at 12:14
    
What is the value of 'textwidth'? The default setting for mail is 72 which should cause your text to wrap near column 72. Also check the value of 'warpmargin'. –  Convict Oct 22 '09 at 10:00
    
I had to use gq to autowrap the text. –  Sridhar Ratnakumar Nov 12 '09 at 22:17
    
There's the following code in ftplugin/mail.vim: if &tw == 0 ; setlocal tw=72; endif - which should set this up properly. –  blueyed Feb 2 '11 at 10:24

I like to run vim (vim7) as:

vim -c "set spell spelllang=en" -c "set tw=72" -c "set filetype=mail"

this turns on the built-in spell checker, line wrapping on word boundaries at 72 characters and file syntax highlighting as email.

share|improve this answer

You want this command:

:set wrapmargin=8

Assuming that your window is set for 80 characters wide. This sets the wrap margin 8 characters from the right hand side, which gives you a width of 72.

You can abbreviate wrapmargin to wm

You may also want to check the email category at this wiki about VIM

share|improve this answer
    
It makes more sense to use :set textwidth=72 (tw) instead, doesn't it? –  blueyed Feb 2 '11 at 10:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.