Wednesday, October 17, 2012

Spell Check: vim tips and tricks


http://www.cs.oberlin.edu/~kuperman/help/vim/home.html

add this to your .vimrc:
if has("spell")
  " turn spelling on by default
  set spell

  " toggle spelling with F4 key
  map <F4> :set spell!<CR><Bar>:echo "Spell Check: " . strpart("OffOn", 3 * &spell, 3)<CR>

  " they were using white on white
  highlight PmenuSel ctermfg=black ctermbg=lightgray

  " limit it to just the top 10 items
  set sps=best,10                  
endif


to have a personal wordlist, make a directory called ~/.vim/spell
you can manually add things your personal wordlist (~/.vim/spell/en.latin1.add):
    printf(              (so printf is invalid, but printf( is ok)
    nextLine()
    ArrayList/=          (the /= means always match case)
    focussed/!           (the /! says treat this as a misspelling)
if you manually add to your wordlist, you need to regenerate it:
    :mkspell! ~/.vim/spell/en.latin1.add


some useful keys for spellchecking:
  ]s       - forward to misspelled/rare/wrong cap word
  [s       - backwards

  ]S       - only stop at misspellings
  [S       - in other direction

  zG       - accept spelling for this session
  zg       - accept spelling and add to personal dictionary

  zW       - treat as misspelling for this session
  zw       - treat as misspelling and add to personal dictionary

  z=       - show spelling suggestions

  :spellr  - repeat last spell replacement for all words in window

No comments:

Post a Comment