On 2016-11-05 18:12, Marko Käning wrote:
> Hi Rainer,
>
> On 05 Nov 2016, at 01:47 , Rainer Müller <[email protected]> wrote:
>
>> On 2016-11-04 18:46, Lawrence Velázquez wrote:
>>> Actually, I might have been thinking about another editor. My vim
>>> highlights the subject in *green* up until 50 chars, and then black for
>>> the overflow. But one can probably change that black to red if they want
>>> :P
>>
>> .vimrc:
>> hi def link gitcommitOverflow Error
>
> thanks for sharing that recipe.
>
> But, this only works in the 50 chars long title.
>
> What about the 72 chars long lines starting at line #3?
Indeed, that is not covered by the syntax rules for gitcommit [1]. You
can achieve this with additional syntax highlighting rules.
So here is the whole thing again with these additions:
---8<---
filetype plugin indent on
syntax on
hi def link gitcommitOverflow Error
autocmd BufEnter *
\ if &textwidth > 0 |
\ exec 'match Overlength /\%>' . &textwidth . 'v.\+/' |
\ endif
hi def link Overlength Error
" or customize it with other colors
"hi OverLength ctermbg=LightRed guibg=LightRed
--->8---
The '*' in the above autocmd is a wildcard match against the filename,
so if you want this for git only, replace it with COMMIT_EDITMSG.
Rainer
[1] /opt/local/share/vim/vim80/syntax/gitcommit.vim