在 Vim 中不使用临时文件读取手册页的方法是什么 [英] What is a way to read man pages in Vim without using temporary files
问题描述
我希望能够在 Vim 中阅读手册页.
I want to be able to read man pages in Vim.
出于某种原因,Vim 似乎无法通过管道读取程序的输出.例如 (man ls) |vi
似乎不起作用,可以解释原因的人的奖励积分.
For some reason, it seems that Vim isn't able to read the output of programs through piping. E.g (man ls) | vi
doesn't seem to work, bonus points for somebody who can explain why.
为了解决这个问题,我一直在使用以下小脚本:
To get around this, I've been using the following little script:
tempo = `mktemp`
man $1 > $tempo ; vi $tempo
这个脚本使用临时文件,我认为它工作正常,但我想知道是否有一种好方法可以在 Vim 中阅读手册页而无需创建临时文件
This script uses temporary files which I guess work fine, but I was wondering if there was a good way to read man pages in Vim without resorting to creating temporary files
推荐答案
由于某种原因,vim 似乎无法通过管道读取程序的输出 […]
For some reason, it seems that vim isn't able to read the output of programs through piping […]
根据man-page,你需要指定一个-
的文件来让它从标准输入中读取;所以:
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)
它创建了一种伪文件并将其传递给 vi
.
which creates a sort of pseudo-file and passes it to vi
.
这篇关于在 Vim 中不使用临时文件读取手册页的方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!