spell checking and vim syntax highlighting

Today I sent out some kernel patches to fix some bug. Our esteemed colleague Randy “eagle eyes” Dunlap pointed out that I had some spelling error.

<rdd> zab: darn, missed the window for s/intead/instead/

How embarrassing! That got me wondering why I don’t have my editor politely raising an eyebrow at me when I misspell things. It is the 21st century, and all. So I read up on syntax highlighting and spell checking in vim. Turning it on is easy enough.

:setlocal spell spelllang=en_us

With that, vim barely hides its true intent behind its default color scheme: to burn a hole in the back of your retina.

MY EYES

Let’s chose some colors that won’t send us into epileptic fits.


:highlight clear SpellBad
:highlight SpellBad term=standout ctermfg=1 term=underline cterm=underline
:highlight clear SpellCap
:highlight SpellCap term=underline cterm=underline
:highlight clear SpellRare
:highlight SpellRare term=underline cterm=underline
:highlight clear SpellLocal
:highlight SpellLocal term=underline cterm=underline

Now misspelled words are underlined and red while other words that it thinks are questionable, for seemingly uninteresting reasons, are simply underlined.

Phew.

Now we can go about our business. z= offers alternative spellings for the word under the cursor, zg adds a word to the list of accepted words, etc.

To round it off we add our own acceptable words list.

:set spellfile=~/.vim/spellfile.{encoding}.add

So there we go! This one’s for you, Randy!

Comments (10) to “spell checking and vim syntax highlighting”

  1. Just wanted to thank you for your life saving comments about changing the vim 7.0 default spell check colors. What were they smoking when they selected those terrible colors!

  2. I’ll second that comment. Hella-better. Thanks for posting this.

  3. Thx, helped a lot !

  4. Only vim 7.0 and above supports this.

  5. thank you, this helped me a lot. colors are fine anyway since I use white-on-black in my dark room to code…

  6. Thanks! Looks very nice.

  7. Much appreciated, with additional kudos for choosing settings that look good in regular or reverse video.

  8. Having played with these a bit more, it seems the ‘highlight clear’ commands clobber spell highlighting when using gvim. It may be worthwhile to ammend them by adding ‘gui=stuff’ attributes to the ‘highlight Spell*’ commands following http://www.vim.org/htmldoc/syntax.html#:highlight

  9. You just saved my eye!

    I doubt if the vim authors are getting any commission from eye doctors for doing this!!

  10. The default spell checker color theme is really a royal pain in the eyes. This is a blessing. Thanks for the great article!

Post a Comment
*Required
*Required (Never published)