Mutt: let vim handle syntax highlighting when viewing plain text attachment

by Dominique   Last Updated October 09, 2019 21:01 PM

I use mutt for e-mail and I let vim handle plain text attachments. In my ~/.mailcap I have

text/plain; view %s ; needsterminal

That works fine, but it removes all syntax highlighting. I often receive source code in attachments, and it'd be great to have syntax highlighting. Is there an option that would allow me to preserve it?

I've also tried vim -R -- %s ; needsterminal in ~/.mailcap but the result is the same.


Answers 2

Put the following in your ~/.muttrc:

set allow_ansi

That, along with your mailcap rule, worked for me to see a .diff attachment with syntax highlighting.

May 12, 2015 14:19 PM

Old question, but I thought I'd share my solution; In my mailcaprc I've added text/plain; vim -u <path to my vimrc> - ; needsterminal(the dash is important)

This allows me open the plaintext in vim with my own config by using the m shortcut when opening the plain-text file as an attachment.

October 09, 2019 20:46 PM

Related Questions

Syntax highlighting for emails

Updated September 21, 2015 17:00 PM

How to set syntax enable permanently in Vim

Updated June 24, 2017 23:01 PM

Pipe to less but keep the highlighting

Updated May 17, 2017 19:01 PM