How can I spellcheck in gVim?

VimSpell Checking

Vim Problem Overview


What is the best way to spellcheck in gVim? Is there an add-on or something? I would like it to offer corrections as well.

Vim Solutions


Solution 1 - Vim

Use :set spell to turn on spell-checking. If it's source code, gvim is smart enough to only spellcheck comments and string literals.

:help spell will give you all the details. Here are some excerpts:

To search for the next misspelled word:

]s Move to next misspelled word after the cursor. A count before the command can be used to repeat. 'wrapscan' applies.

[s Like "]s" but search backwards, find the misspelled word before the cursor.

Finding suggestions for bad words:

z= For the word under/after the cursor, suggest correctly spelled words.

To add words to your own word list:

zg Add word under the cursor as a good word

Also see :help set spelllang for information on changing your dictionary to include other regions, languages, or word sets (for example, medical jargon).

gvim must be compiled with |+syntax|.

I don't put :set spell in my .vimrc because when I'm coding there are just too many variable names in my comments that get flagged. If there is a certain file type you want checked use an autocommand in your .vimrc. Or just turn it on manually when you need it.

Solution 2 - Vim

:setlocal spell spelllang=en_us
:set spell

For spell checker and to activate right button on mouse:

:set mousemodel=popup

When you place the cursor on the word and click on right button, gvim purpose different correct words.

You can put it on your ~/.vimrc

Solution 3 - Vim

Do :set spell to turn on spell-checking. See :h spell for help and info about how spell-checking works and how to use different languages and dictionaries and such.

Solution 4 - Vim

I started using

> aspell

which comes with Cygwin ([http://www.cygwin.com/][1]). (It's a package, but the default install plus manually-added aspell is pretty tiny and quick to download.)

When I want to spell check the current file, I use a function defined in my .vimrc (or _vimrc) that saves the file, runs aspell on it, then reloads the file:

:function! SpellCheck()
:   w!
:   !c:\prog\cygwin\bin\aspell.exe --dont-backup check "%"
:   e! %
:endfunction

to use this function I just do:

:call SpellCheck()

It goes through the file just like Microsoft Word would, I exit, and then the file is reloaded with corrections.

Running aspell externally without having to move my mouse is integrated enough for me. I've never liked on-the-fly spell checking. I find it and things like IntelliSense distracting.

[1]: http://www.cygwin.com/ "http://www.cygwin.com/"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSashaView Question on Stackoverflow
Solution 1 - VimEric JohnsonView Answer on Stackoverflow
Solution 2 - Vimbut2eneView Answer on Stackoverflow
Solution 3 - VimBrian CarperView Answer on Stackoverflow
Solution 4 - VimMatthewView Answer on Stackoverflow