Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

up vote 3 down vote accepted

You could use something like this:

(defun  my-flyspell-auto-correct-and-space ()
  (interactive)
  (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 –  Peter Salazar 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.