Having vim setup for development gives some undesirable effects for editing commit messages (margin not 72, auto-indent typically isn't needed, probably literal tab characters aren't desired, maybe strip trailing space on save?... etc).

What are good filetype options for git commit messages?

function MyFTypeGitCommit()
  " Good options for commit messages.

autocmd FileType gitcommit call MyFTypeGitCommit()

Note, I could post my settings but not sure they're worth promoting for others to use, if someone has this figured out it's likely going to be a more useful answer.

2 Answers 2


I am using this in ftplugin/gitcommit.vim:

" Enable spellchecking
if has('spell')
  setlocal spell

" Automatically wrap at 72 characters
setlocal textwidth=72

Posting own answer, in case others find it useful.

function MyFTypeGitCommit()
  " Check spelling.
  setlocal spell
  " Make bad spelling very obvious! (personal preference).
  :hi SpellBad ctermbg=red ctermbg=white guibg=red guifg=white

  " Never auto-indent.
  setlocal indentexpr=''

  " No literal tabs, indent 4.
  setlocal expandtab shiftwidth=4 tabstop=4

  " Margin for emails, make it obvious where 72 characters is.
  setlocal textwidth=72
  setlocal colorcolumn=+1

  " Strip space on save.
  fun! <SID>StripTrailingWhitespaces()
    let l = line(".")
    let c = col(".")
    call cursor(l, c)
  autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces()

autocmd FileType gitcommit call MyFTypeGitCommit()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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