Quick tips for writing prose with Vim
Vim is a great text editor for programming and web design, but it doesn’t always lend itself very well to writing large amounts of prose. Generally speaking you might want a gui program to take care of that for you like Word, LibreOffice, Scrivener etc…
However, with a few tweaks it’s actually become my editor of choice for writing posts on this site amongst other things. Here’s how I’ve got it rigged.
You may have heard about WriteRoom, the distraction free text editor for Mac. Goyo takes this concept and makes it work with Vim.
You switch it on and the text gets centred, easy to read, the title bars disappear - the focus shifts solely to the text. It’s wonderful.
Goyo acts a lot like VimRoom but VimRoom is no longer supported it seems and, for me, was largely broken. It makes so many buffers and windows that whenever I try to close it, everything flies around the screen. Goyo fixes all these problems.
There are loads of plugins that do this sort of thing but this is one of the few that works without too much hassle. Because there are so many it took me ages to find this one.
There are also loads of ‘clever tweaks’ to put in your
.vimrc that emulate the plugin. These are great but just installing Goyo is so much simpler.
I like to map the Goyo on/off switch to F11, so I have the following in my
map <F11> :Goyo <CR>
From the same developer as Goyo, Limelight puts greater focus on the selected paragraph.
The image above explains it better than I can.
I have one or two lines in my
.vimrc that help make this work.
First I set the colour for the ‘concealed’ paragraphs. The line is set up to work with the solarized colour scheme. Adjust the
241 to your taste:
let g:limelight_conceal_ctermfg = 241
Next I like to map limelight and goyo together to F11:
map <F11> :Goyo <bar> :Limelight!! <CR>
(UPDATE 08/12/14) vim-pencil
This is a really cool add on that does a lot of little things to make life easier in Vim when writing prose. Words wrap nicely (you choose hard or soft wrapping or choose nothing if you don’t care) & the cursor skips through lines not paragraphs.
I used to have a lot of this in my
.vimrc but vim-pencil makes it easy to turn the features on and off when needed - a valuable thing when not in ‘writer’ mode.
There are other features you can find out about for yourself, but all in all vim-pencil has proven itself to be a worthy addition to my vim prose setup.
You should check out the configuration options to customise vim-pencil but so far I have been happy with an extremely simple setup:
map <F11> :Goyo <bar> :Limelight!! <bar> :TogglePencil <CR>
Now, when I hit F11, three cool things happen in one go!
The dictionary is built into vim, so activating it is very easy. I like to map it to F5:
map <F5> :setlocal spell! spelllang=en_gb<CR>
Be sure to change the language to suit you.
With this in your
.vimrc, F5 underlines all spelling mistakes. It’s a toggle so F5 also switches it off.
To jump from one to the other press
] (forward) or
[ (back) then
To open spelling suggestions press
= then choose a number from the list of words displayed.
Optional bonus .vimrc line
All the posts on my site are written in markdown. It’s nice that vim does syntax highlighting for it, but it’s also annoying if you include urls with underscores in etc… I find it simple just to disable the highlighting to avoid these issues:
au BufRead *.markdown set ft=
au BufRead *.md set ft=
That’s it! Two plugins and a couple of
.vimrc lines make vim into a very simple writing environment.