2

I use two languages to check my spelling: English and Russian, so I have the following options in .vimrc:

set spell spelllang=ru_yo,en_us
set spellsuggest=10
set keymap=russian-jcukenwin

Sometimes I run zG on "incorrect" words to mark them as the "good" ones and make the exception globally. After pressing zG I see the following in the status line:

Word 'Timur' added to /tmp/vsqMS8V/10

It seems Vim adds my dictionary preferences/exceptions into temporary directory. Is it possible to specify concrete path where to store such files? There is spellfile option, but I didn't get the idea how to use it with multiple langs..

UPDATE

The are mistake, I should use zg instead zG to store exceptions under ~/.vim/spell permanently and between all vim sessions. But still question is open: how to specify a concrete path/file to store the words?

4

If you want to mark a word as good and that vim remembers it, I think you should hit zg and not zG.

Here's what the help says about zG (:help zG) :

zG Like "zg" but add the word to the internal word list internal-wordlist.

And here's what the help says about the internal-wordlist (:help internal-wordlist) :

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.

On my system, when I hit zg the word is added in ~/.vim/spell/{language}.{encoding}.add.

If you want another location for the file, here's what the help says about the spellfile option :

Name of the word list file where words are added for the |zg| and |zw| commands. It must end in ".{encoding}.add". You need to include the path, otherwise the file is placed in the current directory.

So to choose another location for the file, type :

set spellfile=/path/to/your/file.{encoding}.add

Now, you said that you didn't get how to use the spellfile option to use multiple languages.

The help also says :

For the file name the first language name that appears in 'spelllang' is used, ignoring the region.

If you switch regularly between English and Russian, maybe you should try the following mappings :

nnoremap <silent> <leader>se :setlocal spell! spelllang=en<cr>
nnoremap <silent> <leader>sr :setlocal spell! spelllang=ru<cr>

They will toggle spell check and they will change the value of the spelllang option, which is used for the name of the file storing your exceptions.

It should allow you to have two separate files for two different languages.

  • After asking a question I've already guessed the mistake)) but still..even if I use zg how to specify a concrete file/path to store the words? – Timur Fayzrakhmanov Nov 18 '15 at 19:17
  • 1
    I edited the answer, I hope it will help you. – saginaw Nov 18 '15 at 19:40

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.