Email: bknpk@hotmail.com Phone: +972-54-7649119



 

ASIC/FPGA Design and Verification Out Source Services

vim :: How to run or ignore spell check on given lines / patterns.

  1. 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.

  2. 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.


    1. "ignore spell on text files
    2. "Spell check only lines, which start with a number.
    3. fun! IgnoreStartSSpell()
    4.   "contains=@NoSpell transparent
    5.   "contains=@Spell transparent
    6.   syn match StartS /^[0-9].*/ contains=@Spell
    7.   syn cluster Spell add=StartS
    8.   "no spell for an entire capitalized word
    9.   syn match Cap /\<[A-Z]*\>/ contains=@NoSpell
    10.   syn cluster Spell add=Cap
    11. endfun

    1. map <F3> :call IgnoreStartSSpell()
    2. "autocmd BufRead,BufNewFile * :call IgnoreStartSSpell()
    3. au BufRead,BufNewFile *_notes.txt :se spell


  3. 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.

    1. fun! MyIgnoreSpell()
    2.   se spell
    3.   syn match Cap /http.*\/\/www\..*/ contains=@NoSpell
    4.   
    5.   "ignore function notation like: f(x,y), g(s,t)
    6.   syn match Fun /\w(\w,\w)/ contains=@NoSpell
    7. endfun
    8. au BufRead,BufNewFile web*.txt :call MyIgnoreSpell()

Home

Run a perl script from vim on a block, to do complex text operations

high light your key words with VIM






Search This Site


Feedback This Site




new pages on this site