Cogs and Levers A blog full of technical stuff

Conditionally turning on spell checking in vim

Turning on spell check in vim is easy, you just enter the following command at the prompt:

:set spell spelllang=en_au

Of course you substitute in the language code that suits you. So, when you’re tired of all of the highlighting, you can easily turn it off like so:

:set nospell

I use vim for both general text editing (say, like the Markdown document for instance) as well as for code editing. I really don’t want spell checking on for code editing, so I’ve added the following block to my .vimrc to turn it on for Markdown documents only:

autocmd FileType mkd set spell spelllang=en_au

Finally, if you’ve got a word that you’ve spelt incorrectly and you’re stuck on fixing it - put your cursor over the word and hit z=. You’ll get a list of suggestions to help you!