I have modified my prepare-commit-msg
hook to include the branch name at the beginning of my commit message (e.g. [JCH-234] -
). However, when I run git commit
the cursor is located at the beginning of the editor Vim
. I'm looking for a way to start the cursor at the location following my branch name.
I'm aware that it's only a few extra key strokes to move the cursor however, I believe in attention to detail and would like to implement this if possible.
IMO, this is git config thing, we shouldn't add special vim script/config for it.
You can set GIT_EDITOR
variable like:
GIT_EDITOR="vim -c'startinsert|norm! ggA'"
This makes everytime you git commit, git will hook your pre-commit-msg, then open vim, put cursor at the end of the first line, in your case, after your branch name, also switch to insert mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With