Accessing man pages

4.1
(38)

Did you know you can access man pages from Vim? That’s right, the richly detailed help documentation provided by Unix is available right from with Vim:

  • Press <leader>K on top of any keyword in any file and Vim will open the man page for that program.
  • :Man some_program – Since I don’t often have the names of various Unix utilities written out in my software, using :Man is a bit more practical.

When is this useful? The first can be useful when reading README files, as those sometimes have various executables written out inside of them. I’ve used this on occasion. Do you edit shell scripts often from Vim? Then <leader>K can really come in handy for you.

But :Man has a bit more utility for me. If you’re like me, you try to stay in Vim for as much as of your workflow as possible. When editing text, you might be shelling out from Vim and using normal Unix command line tools, each of which has their documentation in the man pages.

I also like to stay inside of Vim for all my Git operations. Doing so drastically improves my workflow as I avoid context switching back to a terminal. (We wrote a whole course about this!) If I’m ever unsure about a particular Git command, I can access Git’s man pages without leaving Vim. For example:

  • :Man git-log – Show all the various git log options and documentation, without leaving Vim.

To make :Man work, you just need to enable this capability inside your .vimrc with the following line:

runtime ftplugin/man.vim

In the example video below I show you both of these. I happen to have the Ruby package management program bundler mentioned in this README. By pressing \K when on top of bundler, I open the man page for bundler. Next, I check the documentation for git log by running :Man git-log.

How useful was this tip?

Average rating 4.1 / 5. Vote count: 38

No votes so far! Be the first to rate this tip.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Written by

Colin Bartlett

105 Posts

Vim enthusiast and software developer for more than 20 years.
View all posts