writing a book with vim - May 01, 2023


I'm not sure if what I'm experiencing is a renaissance in creativity or just a fleeting interest. I've started writing a book. Aren't we all writing a book? Perhaps the most interesting way I've chosen to do it is in markdown with vim. It really triggered my first journey into configuring vim, so I suppose I'll start there.

Everyone that's worked in technology eventually stumbles across vim and during their first experience, they'll get frustrated, because while brilliantly designed, it's not immediately intuitive to the average user. There aren't any instructions on the screen; which is what I think inspired nano. I don't know that, it's merely speculation, but just to exit you have to type : and then x. But wait, how do you save? Well, of course you type : and then w, but you can also combine them like :wq.

opening vim

Oh yeah, you also have to be in the correct mode for that to work, so to actually make changes you need to type i to enter insert mode. Then, you have to figure out how to traverse the file using the cursor with the correct hotkeys or like you can repeatedly tap the up, down, left, and right arrows until you're in the desired coordinates to make your changes.

Hold on though, to exit insert mode you have to hit esc and then you can :wq get it? Yeah it's pretty easy once you use it a few thousand times to edit config files. That's where my usage of vim started, but now I'm venturing in to the land of configuring it for more than smashing a bunch of hot keys. There's more to life with vim once you start configuring .vimrc. The world is your oyster or whatever. Yeah, raw oysters on the half-shell over ice with hot sauce, lemon, maybe some horse radish...

oysters

Anyway, this is how my first configuration looks and it's stupid simple:

set mouse=a
set textwidth=100

I know it's not that impressive, but that alone enables me to click around in a document to set the cursor position. It auto text-wraps at 100 characters with the setting below that. I'm sure it gets better when I start experimenting with turning it into a full IDE, but for now I'm just writing my book.

Oh yeah! It's also not immediately obvious, but with :set spell spelllang=en_us you set the language. You hop between misspelled words with ]s and [s. Then since you obviously cant spell the word correctly to begin with you'll need suggestions. To get those type z= and you might or might not have an uncle named Bob, but Bob's your uncle, you get suggestions. Select one and move on with your life, because like spilled milk a misspelled word isn't worth crying over.

Anyway back to the book. I'm writing it with markdown because beyond blogging, etc you can do so much with it. I'll probably write something that converts the whole project to a publishable pdf file.