Wednesday, April 12

vim 7.0 spellcheck

Here's a primer on using the new integrated spellcheck feature in vim 7.0:

To turn on spell checking add this to your .vimrc:

setlocal spell spelllang=en_us

or simply:

set spell

which seems sufficient for me. I don't want it for all files, so I added it conditionally for text, html and README files:

autocmd BufNewFile,BufRead *.txt,*.html,README set spell

Then create a directory ~/.vim/spell for vim to hold personal word lists.

Once turned on here's a quick rundown of the basics (of course :help spell is your friend):
  • use ]s and [s to navigate to the next and previous misspelled words.
  • use z= to suggest spelling for a misspelled word
  • use zg to add words permanently to your personal word list. This marks it as a "good" word.
  • use zG to temporarily add words for just this editing session.
  • use zw to mark a word as misspelled.

    There are other shortcuts as well:

  • While in insert mode, use CTRL-x s to suggest spelling for a word to the left of the cursor. You can then select a suggestion from the popup menu.
  • If you enter a common misspelling or mis-capitalization, try the 1z= command which replaces the word with the first spelling suggestion straight away. You can always undo it if it's not the right one.
  • 0 Comments:

    Post a Comment

    << Home