How to enable spell checking in Vim

One task which I do often during writing git commit message is making sure my commit message don’t have any spelling mistakes. I use Vim a lot and today we will see how Vim’s built-in spell checking features can be used for this task.

Content with spelling mistakes
Content with spelling mistakes
:set spell

triggers Vim spell checking functionality on the currently opened buffer.

Vim highlighting misspelled words
Vim highlighting misspelled words
  1. [s  move backward to each misspelled word
  2. ]s  move forward to each misspelled word
  3. z= Once you are on the misspelled word this will show list of suggestions as shown below
Vim showing suggestions
Vim showing suggestions
:set nospell

The above command will turn off the spell check in Vim.

All spellings corrected!
All spellings corrected!

Update:

Adding the following lines to your ~/.vimrc will automatically highlight incorrect spellings during git commit message as shown below

au BufNewFile,BufRead COMMIT_EDITMSG set spell
hi clear SpellBad
hi SpellBad cterm=underline
hi clear SpellCap
hi SpellCap cterm=underline
hi clear SpellRare
hi SpellRare cterm=underline
hi clear SpellLocal
hi SpellLocal cterm=underline
Auto Spell Check in VIM on git commit message
Auto Spell Check in VIM on git commit message