Automatically wrap long Git commit messages in Vim

mgilson picture mgilson · Jun 13, 2012 · Viewed 25.1k times · Source

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.

Answer

Abe Voelker picture Abe Voelker · Jun 13, 2012

Add this to your .vimrc:

au FileType gitcommit setlocal tw=72