Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wish there were a way so that when I mistype a word, flyspell could autocorrect it to the "most likely" correction. When I mistype a word and then hit OPTION-TAB to correct it, flyspell ALMOST ALWAYS picks the correct correction by default as the main suggestion.

However, I want flyspell to do this with every word I mistype, WITHOUT my having to hit OPTION-TAB. Just from hitting the SPACE bar and moving on to the next word.

Is this possible?

share|improve this question
up vote 4 down vote accepted

You could use something like this:

(defun  my-flyspell-auto-correct-and-space ()
  (flyspell-auto-correct-word)    ;; Auto-correct the word at point
  (when (not (or (looking-at " ") ;; If after the correction we are in the
                 (eolp)))         ;; middle of the word, forward to the end
      (forward-word))             ;; of the word.
  (insert " "))                   ;; insert a space

(global-set-key (kbd "SPC") 'my-flyspell-auto-correct-and-space)
share|improve this answer
Wow, thank you, this works perfectly, EXCEPT the keybinding. I get: Warning (initialization): An error occurred while loading `/Users/jay/.emacs': error: Key sequence ⇧S ⇧P ⇧C starts with non-prefix key ⇧S – incandescentman Jan 24 '13 at 23:32
@peter My bad, you can use either (global-set-key " " 'my-flyspell-auto-correct-and-space) or (global-set-key (kbd "SPC") 'my-flyspell-auto-correct-and-space) – Robin Joy Jan 25 '13 at 9:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .