|                             ASIC/FPGA  Design and Verification Out Source Services 
vim :: How to run or ignore spell check on given lines / 
patterns.
This pages gives some tips how to 
control VIM's spell checking.  
It is often required to tell VIM to ignore some lines / patterns from 
being spell checked. For example is non comments lines (i.e. code) of c++ 
program. Or vice versa, run the speller only on comments.
 
I needed this option today. I write often some small read me files with my 
debug notes. Most of the text, in such files, is not required 
to be spelled 
checked at all, because they are path names, code variables etc... Here is how 
to edit the .gvimrc to achieve it:
 
Enable spell check on my text note files. Map function key F3 to spell only my doc notes.
 
 
 
 
"ignore spell on text files
"Spell check only lines, which start with a number.
fun! IgnoreStartSSpell()
  "contains=@NoSpell transparent
  "contains=@Spell transparent
  syn match StartS /^[0-9].*/ contains=@Spell 
  syn cluster Spell add=StartS
  "no spell for an entire capitalized word
  syn match Cap /\<[A-Z]*\>/ contains=@NoSpell 
  syn cluster Spell add=Cap
endfun
 
 
map <F3> :call IgnoreStartSSpell()
"autocmd BufRead,BufNewFile * :call IgnoreStartSSpell()
au BufRead,BufNewFile   *_notes.txt :se spell
 
The next example declares a vim function. The purpose of the function is to
first set spell check on and then instruct the spell checker to ignore web 
addresses. The following lines have to be added to .gvimrc file.
 
 
 
fun! MyIgnoreSpell()  se spell  syn match Cap /http.*\/\/www\..*/ contains=@NoSpell    "ignore function notation like: f(x,y), g(s,t)  syn match Fun /\w(\w,\w)/ contains=@NoSpellendfunau BufRead,BufNewFile web*.txt :call MyIgnoreSpell() |