Accessing man pages
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:
<leader>Kon top of any keyword in any file and Vim will open the man page for that program.
:Mansome_program – Since I don’t often have the names of various Unix utilities written out in my software, using
:Manis 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.
: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 logoptions and documentation, without leaving Vim.
:Man work, you just need to enable this capability inside your
.vimrc with the following line:
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
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?