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>'
  else
    /usr/bin/man "$@"
  fi
}
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.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <div> <img> <h1><h2><h3><sub><sup><b><i><u><font>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
      _   ___   ____          _____  _   _       _____ 
__| | |_ _| | ___| ___ |__ / (_) | |__ |___ /
/ _` | | | |___ \ / __| / / | | | '_ \ |_ \
| (_| | | | ___) | \__ \ / /_ | | | |_) | ___) |
\__,_| |___| |____/ |___/ /____| |_| |_.__/ |____/
Enter the code depicted in ASCII art style.