How to change the hilighted length of git commit-messages in vim

commitgitsyntax highlightingvim

I'm of the opinion that the orthodox 50-character limit on git commit messages is absolutely ridiculous. (Primarily because I think using an 80-character wide Terminal in 2015 is equally ridiculous.) :P

I've fixed a few other glaring issues with vim's default settings for git commit-messages in my vimrc; but vim still hilights the first line if it's longer than 50 characters:

How can I change the line-length at which this occurs?

Best Answer

This is caused by the following line from $VIMRUNTIME/syntax/gitcommit.vim:

syn match   gitcommitSummary    "^.\{0,50\}" contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell

You could just copy that syntax script to ~/.vim/syntax/ and modify it, but that drags you into maintaining your clone. I prefer to selectively change that single syntax definition in ~/.vim/after/syntax/gitcommit.vim:

syn clear gitcommitSummary
syn match   gitcommitSummary    "^.\{0,80\}" contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell

Alternatively / in addition, you could open an issue at the project and ask for a configurable threshold; the hard-coded limit certainly isn't nice.

Related Question