This is the second part of the Series New Series: Writing and Publishing for Command Line Users.
Since my book is written in English, and I am not a native speaker, it would be great to have a spell checking while writing.
Nearly every word processor software comes with pre installed spell checking enabled. So does vim.
How to enable it?
Like mentioned in the first part, I don’t want to have the options for writing enabled while coding, so I put them all into a function called writing.
Check this out here.
And to enable spell checking just add the following line into the function:
setlocal spell spelllang=en_us
If you need another language, for example German, just change it to:
setlocal spell spelllang=de_de
Make sure it installed on your system.
Make use of it
If you followed the steps in ‘prepare vim for writing‘, spell checking should just work as you open a markdown file.
So how do I quickly fix these misspelled words?
You can easily go to next misspelled with ]s or search backwards with [s.
Both options can be used with capitals, for example [S. This will only recognize ‘bad’ words. I’ll explain later what these ‘bad’ words are.
When your cursor is at anywhere in between the word, you have multiple options.
You are sure, that the word is right. For example, my book is about TMUX, so I want to add it to my word list, so it won’t be highlighted again.
To add it type zg.
If you did accidentally like me with ‘tesst’ you can just reverse it with zw.
The first thing you should recognize are the different colors.
‘colour’ is turquoise. stuppid is red, equally to ‘silli’ and ‘english’.
There a different types of highlighting.
For example, colour isn’t totally wrong. In the UK it is ok, but in the US colours is written without an U.
This is a SpellLocal-Error.
Now check if the list contains the correct word you’ve meant to write. In this case it’s the number 1.
So just type 1 and Enter and vim replaces ‘colours’ with ‘colors’. Isn’t that great?
But what’s with stuppid, this is totally wrong and highlighted in red?
This is a so called SpellBad-Error. You can fix this in the same way as with SpellLocal-Errors.
Same with ‘silli’ and ‘english’.
Customize it your way
If you don’t like the colors you can easily adjust them. Just remember to it in your Writing() function.
For example if you’d like to have SpellLocal-Errors with yellow background and black foreground, you’d type this:
highlight SpellLocal ctermbg=yellow ctermfg=black
This works with all the described errors.
I hope you enjoyed reading and it is useful to you.
To stay up to date follow me on twitter or subscribe to the newsletter on the right side.