Skip to content

Instantly share code, notes, and snippets.

@whot
Created April 10, 2014 05:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whot/10345368 to your computer and use it in GitHub Desktop.
Save whot/10345368 to your computer and use it in GitHub Desktop.
vim syntax file for replying to patches/diffs
" Vim syntas file for diffs in an email reply:
" Unmodified diff.vim, all the matches simply have a "> " prepended.
"
" Vim syntax file
" Language: Diff (context or unified)
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2005 Jun 20
" Quit when a (custom) syntax file was already loaded
if exists("b:current_syntax")
finish
endif
syn match diffOnly "^Only in .*"
syn match diffIdentical "^Files .* and .* are identical$"
syn match diffDiffer "^Files .* and .* differ$"
syn match diffBDiffer "^Binary files .* and .* differ$"
syn match diffIsA "^File .* is a .* while file .* is a .*"
syn match diffNoEOL "^No newline at end of file .*"
syn match diffCommon "^Common subdirectories: .*"
syn match diffRemoved "^> -.*"
syn match diffRemoved "^> <.*"
syn match diffAdded "^> +.*"
syn match diffAdded "^> >.*"
syn match diffChanged "^> ! .*"
syn match diffSubname " @@..*"ms=s+3 contained
syn match diffLine "^> @.*" contains=diffSubname
syn match diffLine "^> \<\d\+\>.*"
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.
" Only used when an item doesn't have highlighting yet
hi def link diffOldFile diffFile
hi def link diffNewFile diffFile
hi def link diffFile Type
hi def link diffOnly Constant
hi def link diffIdentical Constant
hi def link diffDiffer Constant
hi def link diffBDiffer Constant
hi def link diffIsA Constant
hi def link diffNoEOL Constant
hi def link diffCommon Constant
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
let b:current_syntax = "diff"
" vim: ts=8 sw=2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment