tags:

views:

145

answers:

3

I want to "set spell" automatically when i am editing the commit text in git. From the % I see that it is writing to a filename called .git/COMMIT_EDITMSG. How do I update my .vimrc to automatically set spell on when editing that file. something on the lines

if ( filename has a word COMMIT)

set spell

fi

+1  A: 
au BufNewFile,BufRead COMMIT_EDITMSG setlocal spell
ephemient
+3  A: 

Ordinarily you could do this using an autocmd (au BufNewFile,BufRead COMMIT_EDITMSG setlocal spell) but recent versions of vim already have a filetype assigned for git commit messages, so what you can do instead is create a file ~/.vim/ftplugin/gitcommit.vim and put this in it:

if exists("b:did_ftplugin")
  finish
endif

let b:did_ftplugin = 1 " Don't load twice in one buffer

setlocal spell

and make sure that you have filetype plugin on in your .vimrc. It's a little more work getting going but it makes it easier to add tweaks in the future. :)

hobbs
I missed your answer but figured "autocmd ...." over the weekend. Thanks for the filetype way of doing it.
A: 

autocmd BufNewFile,BufRead COMMIT_EDITMSG set spell

in ~/.vimrc will do it