I use Vim as my core editor for Git.
I've noticed that, whenever Git fires up Vim following a git commit
(and assuming Vim's syntax
option is enabled), some Vim settings other than my own are applied. In particular, my commit messages get highlighted in a way that I haven't defined anywhere (see below); I use the zenburn
color scheme, but that's irrelevant to my question.
Note, for instance, how the branch name on line 5 is highlighted in a color that is different from that of the rest of the comments.
Additionally, settings that promote the official Git formatting guidelines (see this) are also applied:
- Vim screams at any visible character past the 50th column on line 1, or if the second line is not blank;
- Vim's
textwidth
is set to 72.
Don't get me wrong; I find those Vim settings very useful for writing commit messages. My questions are simply:
- Is Git responsible for those Vim settings?
- If so, where (in what file) does Git store those settings?
- By what mechanism does Git load those settings? Is some Git hook responsible?
Here is a shell script that reproduces the situation:
#!/bin/bash
cd ~/Desktop
mkdir test_cmtmsg
cd test_cmtmsg
git init
touch test.txt
git add test.txt
git commit -m "inital commit"
# oops, made a mistake there
git commit --amend