Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Allow aspell and gvim (vim GUI) interaction UNIX
After searching around for a while and finding that integrating vim and aspell was very easy, I tried the same with gvim. There seemed to be a problem wih the terminal type and the curses interaction. Creating this map in vim (via the .vimrc file) works fine if you run vim within or and have aspell installed (via Fink in my case:
" run aspell over selected text
map ^T :w! /tmp/aspell^M:'<,'>d^M:!aspell check /tmp/aspell^Mk:r /tmp/aspell^M
However, once the GUI for vim is running, the interaction with aspell was pretty useless. So I hunted around for a while and tried launching with AppleScript and telling it stuff, but I failed to get anything really useful to happen. I also found some threads on vim having an internal spelling function. Also, vim version 7 is around the corner so I could wait. But I can't. So, I came up with the following little solution. Basically, it runs an xterm with aspell running in it.

First the vim map. You put this into your .vimrc or .gvimrc file, depending how you're set up.
" run aspell over selected text
map ^T :w! /tmp/aspell^M:'<,'>d^M:!xterm -e aspellit^Mk:r /tmp/aspell^M
Rememeber that ^T is entered using Control-V then Control-T, and the ^M is entered using Control-V then Return. Now the code for ~/bin/aspellit. Make sure ~/bin is in your PATH environment variable, and then put the following code in a file called ~/bin/aspellit:
#!/bin/bash -i
tput reset
/sw/bin/aspell check /tmp/aspell
Remember to make it executable by typing chmod +x ~/bin/aspellit. Now simply highlight what you want spell checked using V, then hit Control-T and an xterm will pop up running aspell over the selection. You can use this idea to run any app that requires curses interaction under gvim.

[robg adds: I haven't tested this one...]
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)

Allow aspell and gvim (vim GUI) interaction | 1 comments | Create New Account
Click here to return to the 'Allow aspell and gvim (vim GUI) interaction' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Insecure temp files
Authored by: TrumpetPower! on Jan 24, '06 07:52:30AM

The .vimrc addition always uses the same temp file, and just leaves it there afterwards. This is very dangerous on a great many levels, even in a single-user environment. In a multi-user environment, it's guaranteed to blow up spectacularly.

Ideally, you want to run aspell as a pipe--have it accept text on stdin and write the corrected text to stdout. If you can't do that, you should write a wrapper script that does that and makes use of mktemp(1) for the temporary files.



[ Reply to This | # ]