如何将所有当前拼写错误的单词添加到 Vim 的拼写列表中?

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

我有一个文件,其中包含很多 Vim 不知道的词。我知道 zg 可以添加一个单词,但是有没有办法将所有“拼错”的单词添加到 Vim 的词典中?

扩展 romainl 的评论。您可以创建一个调用自身的宏:

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 

你看,即使在定义宏时寄存器 q 为空,它也会在执行时被读取。所以一旦你调用你现在定义的宏,它就会调用自己。