Saturday, July 14, 2012

VIM as Mutt Email Editor


So after using mutt for quite sometime as my MAIN email program, this week I decided to up the anti and start using VIM for my email editor and composer. Now I "WAS" a nano fan for quite sometime now. But I have to say that after switching to VIM I am now a VIM convert full-time I think!

It was kind of hard I have to say, to get used to VIM as an editor. The keyboard part wasn't hard, it was memorizing all those special key-strokes that always made it hard for me.

The first thing I did was find a way to make saving and exiting real quick, since I do it alot and don't like having to type a lot to do that simple function. So I re-mapped a few keystroke's so that I had F1, F2 and F3 right at the forefront to Quit without saving, Save and quit real quick and Save and continue editing (Respectively). I wanted to switch to using VIM as my main code editor, I was using Geany which I love. So the F3 save and continue is a must.

So that was first stroke, gotta make it easy. And F key's are easier than Ctrl this and Esc-:-whatever as normal vim work's.

So let's stick to what I did to make it WONDERFUL for an email editor, later we'll talk about Code editor ha ha.

First off I love Mutt so much I downloaded newsbeuter instead of lifearea as my newsreader, I love Mutt! ha ha

First thing I love (and first edit) about VIM is it's ability to auto spell check. The newest version 7.5 comes with a built in spell checker and it's own dictionaries.

But I write email's in both english and spanish. So, first thing's first. Firstly you have to tell Mutt to use Vim, and to turn on spell (default :))

set editor="vim \"+set nonumber\" \"+set insertmode\" \"+set spell\" +/^$/ +9"


That way I automatically use Insertmode when I start so I can just start typing, go to line 9 since I use header's internally and no line number's since it's default in my vimrc file for code editing.

So now spell work's. So second thing I did was setup map keys to F5 and F6 to change spelling language from English to Spanish or visa-versa. First time you switch to spanish "es" it automatically asks you if you want to download that dictionary! Wow! For a console app! Wow!

Work's great! I love the fact that I can edit an email, and while editing, IT auto highlight's mispelled word's, all in terminal! Go to the word that is spelled wrong and hit and it auto pop's up a small window to show me suggestion's! I seem to be loving VIM!

So next thing's next. I always hatted the time Mutt took to lookup an address using Goobook (gmail address book), I would write a new email and hit tab and man it took forever to find it in my Gmail contact's.

So then I changed my header's to in my email editing using:

set edit_headers = yes
set autoedit


So great, now when editing an email I have my To and CC field's right there. Now the real trick, get VIM to lookup those email's. I found a real cool script and I posted it to Pastebin, that basically does the same thing that the spell checker does where it pop's up a window instead of a bunch of replacement's, which take forever.

All I do is go to the to field and start typing, when enough is there I just -, with this wonderful script, that was very hard to find, I got VIM to auto lookup AND pop-up a window showing me email addresses!

The greatest thing is, it took 1/3 the time that mutt took to use goobook!

I'm in love with VIM, real simple :)

The script is here:
http://pastebin.com/tR08XHbF

Copy and paste entirely into your vimrc file and your good to go!

You could even make a shortcut key that worked off of tab if you wanted only on To: CC: and BCC: field's if you wanted.

But I didn't, well haven't yet :)

I have to say I am loving VIM immensely! I don't know why I didn't switch sooner!

For writing email's at least it is awesome. With the added feature of auto highlighted spell check and integrated address book it makes creating email's in VIM an experience.  It was like when I moved from Thunderbird to Mutt for email, the change is so drastic I don't know how I used to use other software!

I thank you to all those Blog post's out there of people who made the switch and praised it!

1 comment:

Anonymous said...

I started using GooBook after reading this. Useful!