I found an automation script written in AutoHotKey very inspiring. It relies on the search result from Google to correct the wrongly spelled words.

The script:

; Ctrl+Alt+c autocorrect selected text
clipback := ClipboardAll
Send ^c
ClipWait, 0
UrlDownloadToFile % "https://www.google.com/search?q=" . clipboard, temp
FileRead, contents, temp
FileDelete temp
if (RegExMatch(contents, "(Showing results for|Did you mean:)</span>.*?>(.*?)</a>", match)) {
   StringReplace, clipboard, match2, <b><i>,, All
   StringReplace, clipboard, clipboard, </i></b>,, All
Send ^v
Sleep 500
clipboard := clipback

Is there a way to construct a similar function in Vim?

  • 3
    You can rely on external tools with vim, such as curl, grep, sed, ... So you could definitely build something like that. But rather than using Vimscript for that, I'd write a script in your prefered language and call it in Vim, parsing its output as the result. If you want to stay with Vimscript, have a look at github.com/mattn/webapi-vim – nobe4 Jan 16 '17 at 7:43

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.