Enhancing the mail syntax vim color scheme for diff

asked 2012-06-14 04:48:57 -0500

shaiton gravatar image

updated 2012-06-15 08:19:29 -0500

Hi, my email client is mutt, and I frequently have to comment diff files attached. My default editor is vim, and it's pretty fast as the diff attached is directly quoted in the email reply.

The problem is that the default mail highlight scheme for vim don't highlight the diff lines. I want to add this support.

I have a sample scheme like the following:

" URL:          inspired from http://vim.cybermirror.org/runtime/syntax/diff.vim

" The following line needs an eye.. "
syn match diffAdded     "^[ >]*>.*"
syn match diffRemoved   "^[ >]*-.*"
syn match diffRemoved   "^[ >]*<.*"
syn match diffAdded     "^[ >]*+.*"
syn match diffChanged   "^[ >]*! .*"

syn match diffLine      "^[ >]*@.*"
syn match diffLine      "^[ >]*\<\d\+\>.*"
syn match diffLine      "^[ >]*\*\*\*\*.*"
syn match diffLine      "^[ >]*---$"

"Some versions of diff have lines like "#c#" and "#d#" (where # is a number)
syn match diffLine      "^[ >]*\d\+\(,\d\+\)\=[cda]\d\+\>.*"

syn match diffFile      "^[ >]*diff.*"
syn match diffFile      "^[ >]*+++ .*"
syn match diffFile      "^[ >]*Index: .*$"
syn match diffFile      "^[ >]*==== .*$"
syn match diffOldFile   "^[ >]*\*\*\* .*"
syn match diffNewFile   "^[ >]*--- .*"

syn match diffComment   "^[ >]*#.*"

" Define the default highlighting.
hi def link diffOldFile         diffFile
hi def link diffNewFile         diffFile
hi def link diffFile            Type
hi def link diffRemoved         Special
hi def link diffChanged         PreProc
hi def link diffAdded           Identifier
hi def link diffLine            Statement
hi def link diffSubname         PreProc
hi def link diffComment         Comment

The problem is that I don't know how to override the default "mail" scheme, I want to keep it whole but for the diff lines. Coping my file in ~/.vim/after/syntax/mail.vim should works, but it keeps the quote colors. Could comes from the "^[ >]* >.*" match.

Any idea?

edit retag flag offensive close merge delete