I scheduled a task using at. The output of the scheduled job was sent to mail. But the output is quite huge; I prefer reading it in a text editor.

Additionally, I don't want to forward the mail, I just want to read locally.

I hope there is a standard way for all *nix. But I use OS X and RedHat.

  • which ditribution are you using (ubuntu ? redhat ? ) – Archemar Oct 26 '15 at 14:26

You can pipe mail to vim, at least on my test system (RHEL 6.7) it worked.

 mail | vim -

the vim - tells vim to read from standard input

you should see output that say's:

Vim: reading from stdin...

at that point just press the number of the mail item you want to read, IE 1 to read the first message,then press ctrl-d to push it forward.


You can open the mail spool file (usually /var/spool/mail/<username>) in vim, but it will contain header information that you probably don't want. Your best bet is to open the message in your mail program, save the message to a file, then open the newly saved file in vim. You'll still have some header information, but much less of it than if you open the mail spool file directly.


I have the following lines in my ~/.muttrc so that I can press F6 while viewing any message to pipe it into less.

macro generic <f6> "|less\n" "view with less"
macro index   <f6> "|less\n" "view with less"
macro attach  <f6> "|less\n" "view with less"
macro pager   <f6> "|less\n" "view with less"

IMO, less is the right tool for this job, but if you insist on vim then change all occurrences of less above to vim -


I hope I'm answering your question correctly, but you can use The Mutt E-Mail Client and configure it to use Vim.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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