Use Vim to read manual page

Command line manual page is an indispensable tool for working with Linux system.If you forget how to use a command, just type man followed by the name of the command. One thing I don't like about the manual system on my Debian sid is that it uses most to display the manual. The key bindings of most feel awkward for me since I am used to vim. Of course, there are many "vimers" like me, and they've found ways to fix this. Actually, there are many different ways, but I find the approach below works best for me. Basically, it involves creating a shell alias for man, so when man is used, shell invokes vim instead to read the manual. The following is added in ~/.bashrc:
# use vim as man's pager, rely on ManPageView plugin
vman() {
  /usr/bin/whatis "$@" > /dev/null
  if [ $? -eq 0 ]; then
    /usr/bin/vim -c "Man $@" -c 'silent! only' -c 'nmap q :q<cr>'
    /usr/bin/man "$@"
alias man='vman'
This script relies on ManPageView plugin. However, I found the bundled syntax highlighting for this plug-in does not work as I expected, so I just deleted ~/.vim/syntax/man.vim. It works because vim 7.0 has manual page syntax highlighting already built-in.


Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <div> <h1><h2><h3><sub><sup><b><i><u><font><img>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Lines and paragraphs break automatically.

More information about formatting options

To prevent automated spam submissions leave this field empty.
Nice place