Categories
geek software tools vim

using vim to write prose

Photo by Chris Lawton on Unsplash

I use Vim to write blog posts, notes and documentation before using another text editor. I don’t consider myself a true writer, but I like to use the speed and shortcuts I know from writing code while I’m writing prose as well.

Vim is primarily a programmers’ editor, so to make it better for general writing, here are a number of tricks and plugins I find useful.

If you are new to Vim/GVim, but interested, you can read about setting Vim up in Windows and how to start configuring it.

Built in spell checker

Vim has a built-in spell checker you can activate with :set spell or :setlocal spell to activate it for the current buffer.
I keep forgetting how to switch it on and off, so I added these shortcuts to my Vim configuration to easily switch spelling on and off again.
With these mappings, I can enable spelling for English or Dutch, and turn it back off. Handy if you write in multiple languages.

" -- Spelling, cause I keep forgotting how to do that
nnoremap <Leader>se <Esc>:setlocal spelllang=en<CR><Esc>:setlocal spell<CR>
nnoremap <Leader>sn <Esc>:setlocal spelllang=nl<CR><Esc>:setlocal spell<CR>
nnoremap <Leader>ns <Esc>:setlocal nospell<CR>

Find out more in the help file with :h spell

Themes

If you’re using GVim on Windows, the default look is just plain ugly. To get a wide range of good-looking color schemes, you only need to install the base-16 vim themes I talked about here. These also look good in a terminal window.

Proselint and ALE

Proselint scans your text for linguistic problems. It isn’t a grammar checker. It’s an aggregation of best writing practices integrated in a command line tool. Used together with the ALE plugin, you can scan your text files automatically with Proselint and get markers in Vim when things are not quite right.

Proselint is a Python tool, so you need to install Python first, then install the Proselint package using the Pip package manager.

pip install proselint

ALE will pick up Proselint automatically and indicate any problems by adding an indicator in the margin.

Proselint highlights a number of problems with blue, squiggly lines.

A bigger font for writing

Vim-fontzoom is a simple plugin to increase your font size. Good for your eyes on small screens, and works excellent in combination with the focus writing plugins listed below.

Previewing markdown

If you are often writing in Markdown format like myself, the Previm preview plugin comes in handy. It renders your Markdown document to HTML and opens it in a browser window. It’s great if you split the browser and (g)Vim window side by side, because it automatically updates the HTML file when you save.

A Markdown preview of this very post.

Focus writing

Get rid of the code editor look Vim sports by default and enter distraction-free writing environment with Goyo and Limelight.
Use :Goyo to remove all distractions, use :Limelight to highlight the current lines you are working on.

Goyo and Limelight for distraction free writing in Vim.

Finding files

If you have folders with notes and other documents in your working folder and subfolders, finding them fast without having to exit Vim is handy.
CtrlP is a great plugin to do just that. Hit the Ctrl-P shortcut and start typing a word that’s part of a file or subfolder somewhere in your current path, to find the file.

Highlighting text

Plain text files are just too plain. With txt.vim you’ll get some “syntax” highlighting for even the most boring of files. Numbers, dates, smileys and bracketed text look better with this little plugin.

Markdown files already have syntax highlighting in Vim, so you don’t need an extra plugin for that.

Text completion

If you made it this far, you’re a pretty hardcore Vim user already. So why not take it up another notch? CoC or Conquer of Completion is a plugin that masters code completion for all sorts of programming languages.
It’s also useful for any type of text document. Any word in your document is ready to be reused for automatic completion in Vim. Type half a word, or a few letters, and it presents you a list of already typed words from the current buffer. Handy if you frequently use long and complex names, like for writing documentation or science-fiction.

I use this together with Supertab, which makes it easy to complete words by pressing tab. Just like I’m used to in other editors for programming.

More Vim writing resources

In a VimConf 2021 session Theena Kumaragurunathan (an actual writer) demonstrates his writing an world building workflow using Vim.

He also has the GitHub repository OVIWrite up with a Vim configuration setup for writers. I’m not sure if you can just copy and paste this setup, but it’s an interesting starting point to see what plugins he’s using.

I noticed quite a few plugins that I highlighted here, so I guess I’m on the right track. :)

One reply on “using vim to write prose”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.