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
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.
This is the first part of the Series New Series: Writing and Publishing for Command Line Users.
As I am writing on my first book I recognized, I need a different environment than for coding.
While coding python or C I got my autoindentation, syntaxhighlighting, line numbers and a lot of stuff that becomes disturbing while writing.
I need to turn it off.
The first attempt was the following:
Create a separate .vimrc for writing.
So I created a file .writing_vimrc and added an alias
alias wvim="vim -u BRALALALA"
NO, STOP DOING THIS, THAT’S STUPID!
Vim has so many nice features, so don’t waste your time with bullshit like that.
My second attempt was better. I write my book, notes and blog posts in markdown all the time.
If you got “filetype on”, vim already knows that it’s markdown, so why don’t use this?
So I created an autocmd for markdown files, which works like this:
autocmd FileType markdown call Writing()
What happens here is, vim runs the command “call Writing()” everytime it recognizes the filetype ‘markdown’.
Of course you need to define a function called “Writing()” where you declare, what should happen, to get a noisefree workspace in vim.
Here’s mine for example:
set nonumber " turn off the line numbers
set laststatus=0 " turn of my status bar
set columns=80 " define a smaller window for better
setlocal spell spelllang=en_us " define a language for spell checking(more in the next article)
Now you got a clean vim environment.
If you questions just drop a line in the comments.
Interested in a book about a productive workflow on the command line? Sign up for my book!
As I am about writing a book about tmux and stuff, I learned lot of stuff.
Stuff which is necessary in a book, so this is start of a new category 😉
I am a command line guy, so where do I write my book? Right, on the damn command line!
As my editor I use my loved VIM with a few tweaks which make it easier to write a book instead of code.
While I go on writing I recognize new stuff everyday I never cared about before.
I’ll write about random stuff, like writing, rendering, converting and publishing on the way to my first book. If you got questions how I do something don’t hesitate to ask me.
I created a new community in Google Plus where you could show your desk setup or get ideas from other users.
So just take a look and have fun!