Skip navigation

Sure, why not :)

This goes in your zshrc:

  vman() {
    if [ $# -eq 0 ]; then
      if man -w $* >/dev/null 2>/dev/null
        /usr/bin/man $* | col -b | vim -c 'set ft=man nomod' -
        echo No man page for $*
  alias man='vman'

And this goes in your vimrc (in a suitable augroup):

  autocmd FileType man setlocal ro nonumber nolist fdm=indent fdn=2 sw=4 foldlevel=2 | nmap q :quit

Now you’ll get nicely highlighted man pages with folded sections, and you can hit q to quit just like less.

Vim as a manpage viewer


  1. A solution to the above problem, and also a different approach:

    (a) Inside a directory in your $PATH (say, ~/bin), create a file called ‘_man2vim’, containing the following:

    #!/bin/sh col -b | vim -c ‘set ft=man nomod’ -

    Make this file executable.

    (b) Wherever it is you like to add aliases (be it .bashrc, .bash_alises, .zshrc or anything else), add the following alias:

    alias man=’man –pager=_man2vim’

    (c) VoilĂ .

    • itai
    • Posted April 29, 2009 at 07:33
    • Permalink

    Very cool!

    Two comments: A. You might want to use “nmap ” instead of “nmap”. B. This breaks man page autocompletion – instead of being offered man pages, you’re offered files in the current directory (as you would be for vim). Any ideas how to fix this?

  2. This is sick, perverted, and … I like it :) Although I’m too lazy to actually use it :D

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>