Vim as a Man Page Viewer

December 20, 2014

Man pages are an essential part of every developer’s workflow. Unfortunately, the default system pager less isn’t the best interface. That’s why I wrote a Vim plugin and a short shell function to take care of opening man pages in Vim.

The Plugin

If you’re eager to dive right into the source or to install the plugin, head on over to the GitHub repository. It’s a whopping 32 SLOC, so feel free to peek under the hood.

Why?

You might be thinking, “But Jake, man works just fine for me, why would I switch?” I’m glad you asked!

Mouse Support

The first reason why I was interested in getting man pages to open in Vim was because I wanted to be able to scroll with the mouse. When I have to read man pages for a long time, usually as a part of some more all-encompasing bit of research, I find scrolling to be a much better interface for quickly perusing the content of a man page.

Syntax Highlighting

As it turns out, man pages have a syntax to them, and Vim does a pretty excellent job at highlighting them. Rather than talk about it, here are some screenshots. Note how code samples (C system calls and library functions) are also syntax highlighted appropriately.

Example 1
vman vim

Example 2
vman 3 printf

All the benefits of Vim

While less makes a good effort to emulate certain Vim keybindings (or maybe it’s the other way around, I don’t know which came first), less certainly falls short of the full power of Vim.

For example, once you’ve opened a man page in Vim, you can open a new tab or split side-by-side with the man page. Especially if you’re switching between Vim and the man page often, being able to open man pages in tabs or splits is invaluable.

Mine doesn’t look like yours!

A couple of my other plugins are showing in the screenshots above. I’m using the Solarized Dark color scheme, the plugin vim-airline to take over the statuslines at the very top and bottom, and iTerm2 on Mac OS X 10.10.

You can see my complete configuration on GitHub.

Feedback

As a matter of fact, this was my first Vim plugin! If you notice anything out of place, even if it’s a small detail, I’d love to hear it. Make no assumptions about the reasoning behind why certain decisions were made, because I have none XD

Testing, Types, & Correctness

It’s important to both have strong testing practices and languages with disciplined type systems. The hardest part of writing quality software is ensuring that it runs without bugs. This is why testing and type systems are complementary—they’re distinct tools to help us write better code. Continue reading

If, Else, & Purity

Published on September 01, 2017

Haskell Development with Neovim

Published on July 16, 2017