Spell check of word below cursor
From Vim Tips Wiki
Tip 633 Previous Next Created: January 8, 2004 Complexity: intermediate Author: Anon Version: 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 -- <CR> map <A-d> :!echo <cword> \| ispell -d danish -a -- <CR>
Spell check words in either English or Danish.
[edit] Comments
<A-e> is Alt-e. I've mapped it to ,s:
map ,s :!echo <cword> \| ispell -a -- <CR>
You can append ;read after the pipe to be able to see the actual output from ispell.
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.
