Using Git, my editor for commits is Vim. I'm constantly doing a poor job of remembering to wrap lines and so I get long lines (see this answer for example). Is there a way using some git config
or .vimrc
magic that I can get Vim to automatically wrap lines at 72 columns?
Related question.
Body line length limited to 80 characters The line length for the body text of a commit message should be constrained to 80 characters. Regardless of if you manually wrap the body line length to 80 characters or not, the body text will appear as wrapped as 80 characters in the GitHub UI.
The ideal size of a git commit summary is around 50 characters in length. Analyzing the average length of commit messages in the Linux kernel suggests this number.
Add this to your .vimrc
:
au FileType gitcommit setlocal tw=72
While the other answers solve this problem perfectly well, I highly recommend you install Tim Pope's fugitive.vim.
fugitive.vim is an excellent plugin that brings Git functionality to Vim. It has a whole host of features that aren't relevant to your question, but are worth checking out. However, it can also help you remember to keep your commit messages the proper length:
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