Temporarily declare a word as wrong in vim spellchecker

730 views Asked by At

I'm writing a document with vim and latex. I recently noticed a word that I use ("tree"), but which is incorrect in the context of my document. I corrected it on the whole document. However, I have the habit to use this word instead of the correct one, when writing.

Is it possible to declare this word as a temporary wrong word (until the buffer is closed, this is enough), to make the spell-checker highlight it?

I have tried to mark it as definitive wrong word. This is not a solution as "tree" is in fact a correct word and should not be highlight in other documents. I also tried to search it: my vim is configured to automatically highlight it when I write it. This is a half-solution, as it needs that my last search be "tree", and handles difficultly many words if I have really wrong habits.

2

There are 2 answers

0
lcd047 On BEST ANSWER

Vim spell cheat sheet:

  • ]s / [s - next / previous misspelled word
  • ]S / [S - next / previous bad word (i.e. as above, but ignore rare words and the like)
  • zg - add good word to the first dictionary in spellfile; remove it with zug
  • zG - add good word to the internal wordlist; remove it with zuG
  • zw - add bad word to the first dictionary; remove it with zuw
  • zW - add bad word to the internal wordlist; remove it with zuW
  • z= - suggest correctly spelled word.

According to the documentation,

The internal word list is used for all buffers where 'spell' is set. It is not stored, it is lost when you exit Vim. It is also cleared when 'encoding' is set.

So this is what you are looking for.

Please see :help spell-quickstart for more details.

0
Kristján On

You can set a match in your buffer, which will vanish when you close it.

:match Error /tree/

To only match the whole word "tree", use \< to match the beginning of the word and \> to match the end.

:match Error /\<tree\>/

:match documentation: http://vimdoc.sourceforge.net/htmldoc/pattern.html#:match