MYV MYV - 11 days ago 10
Linux Question

What is a way to read man pages in vim without using temporary files

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

Answer

For some reason, it seems that vim isn't able to read the output of programs through piping […]

According to the man-page, you need to specify a file of - to get it to read from standard input; so:

man ls | vi -

If that doesn't work, you might try using process substitution:

vi <(man $1)

which creates a sort of pseudo-file and passes it to vi.