I have a setting (namely highlight the 81st character on the line) that I would like to turn off when there is a diff. This is easy enough as a search through the autocmds results in:
|FilterWritePre| starting to write a file for a filter command or diff
|FilterWritePost| after writing a file for a filter command or diff
So I end up with:
" Highlight the 81st character on the line if it's not the quickfix. autocmd BufReadPost * if (&filetype != 'qf') | \ let b:ColorColumnID = matchadd('ColorColumn', '\%81v.') | \ endif " When diffing take out the coloring because it looks like diff highlighting. autocmd FilterWritePost * if (&diff && exists('b:ColorColumnID')) | \ call matchdelete(b:ColorColumnID) | \ endif
However, I would also like to turn the setting back on when I leave diff mode. As far as I can tell, there's no autocmd to detect this, and I can't think of any other robust ways to do it. Obviously I could check
&diff on every cursor move or something like that, but I'm hoping for something a little less hacky. Any ideas?