sponsor Vim development Vim logo Vim Book Ad

intermediate Tip #633: spell check of word below cursor

 tip karma   Rating 37/16, Viewed by 2952 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   January 8, 2004 3:42      complexity:   intermediate
author:   nobody      as of Vim:   6.0

poor man's grep of spell checking for unix based systems

requires aspell/ispell to be available in path or use full path in map command

map <A-e> :!echo <cword> \| ispell -d british -a -- <return>
map <A-d> :!echo <cword> \| ispell -d danish -a -- <return>

spell check words in either english or danish

 rate this tip  Life Changing Helpful Unfulfilling 

<< Setting the font in the GUI | To view all colours available to gvim >>

Additional Notes

[email protected], January 11, 2004 1:30
Very nive tip.

ThanQ very much.
[email protected], January 14, 2004 7:41
This probably deserves an RTFM, but what does "map <A-e>" map to?  Meaning what keys do I hit to run the command?
[email protected], January 14, 2004 7:49
Nice tip, I've been looking for something like this.

I don't know what <A-e> maps to, but I've mapped it to ,s (which is easier to remember!)

map ,s :!echo <cword> \| ispell -a -- <return>
[email protected], January 22, 2004 13:42
<A-e> maps to Alt-e as per the manual
[email protected], March 8, 2005 11:00
you can append ;read after the pipe to be able to see the actual output from ispell
RichardBronosky ([email protected]), March 31, 2006 10:23
My little twist on this:
  to search the word under the cursor in normal mode:
    :nmap sp :!echo <C-r><C-w> \| aspell -a<CR>
  to search the current visual selection:
    :vmap sp y:!echo <C-r>" \| aspell -a<CR>

Now, if you want to check the word under the cursor in Insert mode, you can do:
<Ctrl+O>sp

I'm not sure I like the keystroke "sp" for normal mode, since I use vim's default mapping of "s" (:he s) a lot.  this would only conflict if I wanted to "s" and insert something that started with a "p".  I'll change it if it becomes a problem for me.  You can do the same.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo