Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM set spell in file .git/COMMIT_EDITMSG

Tags:

vim

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

like image 539
user205315 Avatar asked Nov 06 '09 22:11

user205315


3 Answers

This line works for me:

autocmd FileType gitcommit setlocal spell
like image 74
Keith Smiley Avatar answered Nov 12 '22 03:11

Keith Smiley


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. :)

like image 26
hobbs Avatar answered Nov 12 '22 05:11

hobbs


au BufNewFile,BufRead COMMIT_EDITMSG setlocal spell
like image 11
ephemient Avatar answered Nov 12 '22 03:11

ephemient