How to add all currently misspelled words to Vim's spell list?

Viewed 57

I have a file that contains many words Vim doesn't know. I know zg can add a single word, but is there a way to add all "misspelled" words to Vim's dictionary?

1 Answers

To expand on romainl's comment. You can create a macro that calls itself:

qqq        " clear register q
qq]szg@q   " create a macro in register q that steps to the next spelling mistake
           " add it to the wordbook and call the macro at q (currently empty)
@q         " call the macro at the register q 

You see, even though, register q is empty at the time you define your macro, it will be read at execution time. So as soon as you call your now defined macro, it will call itself.

Related