Could git open vim editor at line N whenever we are creating commit?

94 Views Asked by At

I working in a project where each commit in a branch MUST start with

Story PRJCT-NAME-42 Task description

And must contain a message like this

Story PRJCT-NAME-42 Task description

foo bar description

I've created a custom message and stored in ~./gitmessage. The content of the file is

Story PRJCT-NAME-42 Task description

It is possible t run git commit and have focus in line number three?

1

There are 1 best solutions below

1
On

Add this line to your ~/.vimrc:

autocmd BufNewFile,BufRead COMMIT_EDITMSG :3

This will move the cursor to line #3 whenever a file called COMMIT_EDITMSG is opened (which is the name of the temporary file used by git while editing a commit message)