Vim — Spell Checking
Vim is an awesome source code editor but its also a text editor. So it suports spell checking. A lot of people don’t know this. Support for spell check was added to Vim 7. To enable spell check:
or add this into your
.vimrc by using the following command.
echo "set spell" >> ~/.vimrc
Once enabled, Vim will highlight wrong spellings by underlining them. Such as the one in following picture.
It’s good to highlight wrong spellings but it’s even better if it can corrent it. To fix the bad spelling, place the cursor on the word and use the following command.
Note: This needs to be used in NORMAL mode.
This will show you the list of suggestions for what might be the corrent spelling of the word.
Typing the index number will result in replacing the bad spelling with one in front of index number.
If you want to fix all the similar bad spellings in the same buffer, use the following.
But what if you are using the correct spelling it’s just that, Vim’s dictionary does not contain that word. In that case you might want to add that word for later use. To add letter, place the cursor over the word and use the following command in NORMAL mode.
Instead, if you just want to add that word for this session, then use this.
Similarly, if you want to remove the word from dictionary or mark a spelling as bad, use the following command.
If you want to mark spelling as bad only for this session then use this instead.
Note: In ArchLinux, by default only English language dictionaries are installed.
Dictionaries for other languages can be found at
ftp.vim.org. To add and enable those dictionaries,
place them in
~/.vim/spell/ directory and enable them by the following
:setlocal spell spelllang=en_us
en_us with name of the dictionary.