1

I write in German and English and my text sometimes deal specific topics.

This lead me to use multiple spelling files for different kinds of texts. The advantage for example is when I write in German and I have many topic specific English words I don't add these words to the German spelling file.

set spellang=de_de,security,protocols

For this I wrote a script/vim mapping to decide into which file a new word should be added.

But I often have the problem when I write a text about a new topic, I have to add a lot of new words. When I start spell checking I then first get rid of all the obvious errors and I'm left will all the new words and I would like to see all these words and sort and filter them in a compressed view, to add them into the spell files.

How could this be made possible? Is there a way to have all misspelled words in a new buffer?

2
2

That sounds like a perfect use case for my SpellCheck plugin: It provides a :SpellCheck command that puts all spelling errors into the quickfix list. You can review them there and directly add them into spell files via overloaded zg, zw, etc. mappings.

1

After finding this question and answer while trying to solve this problem for myself, I wondered if the spellcheck commands were macro-able.

It turns out, yes, they are.

There may be other, more elegant solutions (or a plugin as was mentioned in the accepted answer), but for a quick way to just yank all the spelling errors this is another way around the problem.

  1. Run :setlocal spell in command mode to turn on spellchecking
  2. Open a new blank tab for editing :tabedit
  3. Return to original buffer, and start recording Vim Macro by pressing q and assigning it to a letter (e.g. qs)
  4. Record Macro with the following keystrokes to yank and paste misspelled words each on their own line in the new tab: ]sywgtpo<Esc>gt
  5. Stop recording Macro by pressing q
  6. Recorded Macro can now be ran as many times as necessary until end of buffer is reached. (e.g. 500@s)
2
  • If you started with ]s before recording and ended the macro with ]s, you could make a recursive macro (so invoking it needs no count to process the whole buffer). Also see g<Tab> to switch between two tabs more robustly than gt
    – D. Ben Knoble
    Oct 3 at 18:19
  • Hi, yeah this is a nice solution, which only uses vim. But for my use case this would be to tedious. I kinda solved this for me with my addword script and a mapping. github.com/raphaelahrens/shutils/blob/master/addword This workflow was ok for 4 years, but I guess I will have to rewrite this in lua for neovim. Oct 4 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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