Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to correctly set the spellfile in VIM?

Tags:

vim

I'm trying to use spellchecker in vim; if I want to add a word to the internal dictionary (so that it is not highlighted as wrong) by the zg command, it says "option spellfile is not set".

I tried to type :set spellfile=PATH.../.vim.spell,

but I always get "Invalid argument: spellfile=PATH.../.vim.spell". Any hint please?

I'm using linux Ubuntu 12.04.

like image 748
Peter Franek Avatar asked Jun 05 '14 07:06

Peter Franek


People also ask

How do I set spell check in Vim?

vim Spell checker Spell CheckingTo turn on the vim spell checker run :set spell . To turn it off run :set nospell . If you always want the spell checker to be on, add set spell to your vimrc. You can turn spelling on only for certain filetypes using an auto command.

Where is Vim Spellfile?

This spellfile by default is stored in the directory ~/. vim/spell and its filename is of the format lang.

How do you add words to Vim dictionary?

To add words to your own word list: zg Add word under the cursor as a good word to the first name in 'spellfile'. A count may precede the command to indicate the entry in 'spellfile' to be used. A count of two uses the second entry. In Visual mode the selected characters are added as a word (including white space!).


2 Answers

You cannot choose an arbitrary name. :help 'spellfile' says:

It must end in ".{encoding}.add".

So, use a syntax like this (and ensure that the spell directory exists):

:set spellfile=~/.vim/spell/en.utf-8.add

For encoding, check :set encoding? (Technically, it's the buffer-local 'fileencoding' setting, but that most defaults to the former.)

like image 185
Ingo Karkat Avatar answered Oct 10 '22 22:10

Ingo Karkat


Maybe you should just do mkdir ~/.vim.

By default, the spell files are stored there. But if vim could not find that folder, it will complain with this error message.

like image 9
Jagd Avatar answered Oct 10 '22 23:10

Jagd