Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to color a diff quoted by Mutt in Vim?

Tags:

vim

diff

colors

What is the best way to color diff, quoted in Mutt, using Vim?

If I receive a diff as attachment, I want to comment some lines, but while replying mutt adds the quotation mark (>) which is fine for me, but then it breaks the diff coloration in Vim.

How to add to the current diff pattern to match even with the first > chars? (It would be better to match more ^[> ] patterns)

Example of diff quoted message:

> @@ -52,22 +48,17 @@
> -msgid "foo is deprecated."
> +msgid "bar is deprecated."
like image 553
Shaiton Avatar asked Nov 10 '11 12:11

Shaiton


1 Answers

I'd start by writing a custom syntax file, say ~/.vim/syntax/muttdiff.vim:

syn match quote "^>* "
syn match quotedDeletion "^>* *-.*" contains=quote
syn match quotedAddition "^>* *+.*" contains=quote

hi quotedDeletion ctermfg=red
hi quotedAddition ctermfg=green
hi quote ctermfg=white

And make vim source the file if it is editing a mutt message.

It's a good start if you want to learn how to create a custom syntax file for vim.

like image 105
holygeek Avatar answered Oct 19 '22 18:10

holygeek