Vim Spell Checking
There are times when we edit prose in Vim,
such as in a project
README or Git commit message.
In those cases,
we can use Vim's spell-checking to help us avoid embarrassing mistakes.
We can switch on spell checking with this command:
We can also specify the language:
:setlocal spell spelllang=en_us
Here's a screenshot of what I see as I edit this blog post:
The highlighted words are considered misspellings.
It would be tedious to manually turn on spell-checking each time we need it. Luckily, we can guess by convention that we'll want to spell-check certain files.
We automatically turn on spell-checking for Markdown files based on their file
extension with this line in our
~/.vimrc via thoughtbot/dotfiles:
autocmd BufRead,BufNewFile *.md setlocal spell
Another way to do it for certain filetypes is like this:
autocmd FileType gitcommit setlocal spell
By turning on spell-checking in our
~/.vimrc, we'll be turning on word
completion as well. The following command will let us press
CTRL-P in insert-mode to complete the word we're typing!
We can add words like "RSpec" or "thoughtbot" to the
(a list of correctly-spelled words)
by cursoring over those words in a file and typing: