For some context, I'm talking about Git commits specifically. The Linux server that I use for work changes the color of the first line starting from column 53 (since 52 is the recommend commit title length) and for the body after column 70 the words wrap to the next line automatically.

How do I configure Vim to do this?

  • What you want is the default behavior if you enable syntax highlighting: syntax on.
    – romainl
    May 10 at 15:43
  • Did you found a solution to your problem? How can we help you further? May 11 at 15:14

2 Answers 2


You can override the gitcommit file type by adding a gitcommit.vim file into: ~/vimfiles/after/ftplugin.

To change the body width to 50 you could add to the file:

setlocal textwidth=50

The first line warning is probably a specific colorization using a regular expression of the kind \%>52v.


Your question is a bit unclear whether you want to enable this behavior on your machine or change it. Since Vivian already explained how to override filetype settings, I'm going to talk about the other things.

The syntax highlighting and textwidth are set in two files called gitcommit.vim. One is located in $VIMRUNTIME/syntax, the other one in $VIMRUNTIME/ftplugin. These files come with Vim.

To set the filetype for the current buffer, write set filetype=gitcommit.

To have automatic filetype detection, put :filetype plugin on in your vimrc.

As always, refer to :help for the options mentioned above.

It's also possible to define new filetypes or define aliases. I once did this to apply git syntax highlighting to svn commit messages (not perfect but better than nothing).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.