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.

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.

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!
Stephen Birch wrote:
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!
Posted on 03-Mar-07 at 8:39 am | Permalink
James wrote:
I’ll second that comment. Hella-better. Thanks for posting this.
Posted on 02-Jul-07 at 7:22 am | Permalink
Uli wrote:
Thx, helped a lot !
Posted on 18-Jul-07 at 12:30 am | Permalink
Swarup wrote:
Only vim 7.0 and above supports this.
Posted on 18-Sep-07 at 5:07 am | Permalink
dante_2core wrote:
thank you, this helped me a lot. colors are fine anyway since I use white-on-black in my dark room to code…
Posted on 07-Nov-07 at 1:28 pm | Permalink
Matt wrote:
Thanks! Looks very nice.
Posted on 30-Nov-07 at 1:44 pm | Permalink
Rhys Ulerich wrote:
Much appreciated, with additional kudos for choosing settings that look good in regular or reverse video.
Posted on 24-Jan-08 at 7:54 am | Permalink
Rhys Ulerich wrote:
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
Posted on 24-Jan-08 at 8:17 am | Permalink
Chunhua Liao wrote:
You just saved my eye!
I doubt if the vim authors are getting any commission from eye doctors for doing this!!
Posted on 27-Mar-08 at 2:11 pm | Permalink
Seth Kriticos wrote:
The default spell checker color theme is really a royal pain in the eyes. This is a blessing. Thanks for the great article!
Posted on 25-Jun-08 at 11:01 pm | Permalink