I want to be able to read man pages in vim. For some reason, it seems that vim isn't able to read the output of programs through piping (i.e '(man ls) | vi' doesn't seem to work, bonus points to somebody who can explain why), and to get around this, I've been using the following little script:
tempo = `mktemp`
man $1 > $tempo ; vi $tempo
This script uses temporary files which I guess works fine, but I was wondering if there was a good way to read man pages in vim without resorting to making temporary files
Vim includes a man page viewer, :Man
, in its runtime files.
Put this line in your vimrc:
runtime! ftplugin/man.vim
Now you can read syntax-highlighted man pages inside Vim by running :Man
. For example:
:Man 3 printf
Even better, you can just place your cursor on a word in the buffer and press <Leader>K
(\K
) to see the man page for that word.
See :h find-manpage
for complete usage and installation instructions.