I'm trying to modify my filetype.vim such that it highlights a unified diff file with diff syntax, overriding whatever syntax is normally associated with the file's extension.
So far, I'm just trying to see if the first line in the file begins with
---. However, what I have will treat the file as a diff if any line begins with
au BufRead,BufNewFile * \ if search('^---', "n") | \ set filetype=diff | \ endif augroup END
I've tried various combinations of setting the cursor position, adding a stop parameter to
search, but nothing I've tried works.