Automatically wrap long Git commit messages in Vim
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:
Add this to your .vimrc
:
filetype indent plugin on
From here.
2018 Update - Update vim
If you update vim, it will automatically highlight the first 50 characters of your title and wrap lines at 72 characters. It knows that you're editing a git commit file.
Mac users can use Homebrew:
brew install vim
If you still aren't seeing the syntax highlighting, make sure you have it enabled:
You need to have following settings in .vimrc file as per arch linux documentation
filetype plugin on syntax on
In addition to other answers, use gqip
to reformat a paragraph while editing.
See Vim Tips Wiki: Automatic formatting of paragraphs