I recently came across an embarrassing typo on my own website. Buried deep in a paragraph of HTML inside a Rails HAML template, there was a glaring spelling mistake. I quickly raced back to Vim and opened the template and spell checked the whole file. How? With :set spell
.
Many novice Vim users are unaware that spell checking is built in and as easy as enabling with :set spell
. As a veteran Vim user, I was aware of spell checking and how to turn it on, but I frequently forget the full complement of commands. So for anyone that needs reminding, here are the basics for getting the most out of Vim’s spell checker:
:set spell
- Turn on spell checking:set nospell
- Turn off spell checking]s
- Jump to the next misspelled word[s
- Jump to the previous misspelled wordz=
- Bring up the suggested replacementszg
- Add the word under the cursor to the dictionaryzw
- Oops! Undo and remove the word from the dictionary
In the screencast below, I’ve demonstrated a few of these. With the file open, :set spell
has already been enabled. I find the first misspelled word with ]s
. It’s actually correctly spelled, it’s the name of my status page monitoring service, StatusGator. So I add the word to the dictionary with zg
. Then I find the next misspelling with ]s
and press z=
to pull up the suggestion list. Finally, I press 2
to choose the replacement.
Was this useful? Help us improve!
With your feedback, we can improve VimTricks. Click a link to vote: