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
This line works for me:
autocmd FileType gitcommit setlocal spell
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. :)
au BufNewFile,BufRead COMMIT_EDITMSG setlocal spell
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With