vim / writing

Reading time:
2 min. | 234 words

One of my favorite functions I have added to my .vimrc file recently is Word Processor Mode inspired by Seth Brown. When I am writing code I do not usually care to have wrapping on by default, but when I am writing prose I want lines to wrap as I write. To work around this the Word Processor function calls up line wraps as well as a few other features that can be useful in writing. The function looks like this:


func! WordProcessorMode()
    setlocal formatoptions=t1
    setlocal textwidth=80
    map j gj
    map k gk
    setlocal smartindent
    setlocal spell spelllang=en_us
    setlocal noexpandtab
endfu
com! WP call WordProcessorMode()

Now when working in Vim, I type :WP and the environment changes for me to write. The function wraps lines at column 80, I mapped j and k to make paragraph navigation easier, and enabled spell check. A handy function to have in your toolkit when you do your writing in Vim.

Incidentally, Chad Black wrote the first in a series of posts today about “Vim Scrivener” that I will be following closely as well. Like Chad, I love Scrivener for writing but I get nervous about storing everything inside their database and tying things to a proprietary application. Almost everything I work with is plaintext and Markdown, and in some ways Scrivener is overkill for my needs. Word Processor Mode is the start of my own explorations into going back to Vim for my writing needs, so Chad’s posts will be quite useful as I look into customizing Vim for writing.


About

Greetings! My name is Jason Heppler. I am a Digital Engagement Librarian and Assistant Professor of History at the University of Nebraska at Omaha and a scholar of the twentieth-century United States. I often write here about the history of the North American West, technology, the environment, politics, culture, and coffee. You can follow me on Twitter, or learn more about me.

Where

Search