为什么不"历史| VIM"工作? [英] Why doesn't "history | vim" work?

查看:264
本文介绍了为什么不"历史| VIM"工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要利用Vim看到的结果历史(而不是在shell)。我觉得历史| VIM 将工作(使用的结果历史作为输入 VIM ),但它返回:

I want to use the Vim to see the result of history (not in the shell). I think history | vim will work (use the result of history as the input of vim), but it returns with:

$history | vim
Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...

Vim: Finished.

有人能解释一下吗?

Can anybody explain this?

推荐答案

通过管道进入 VIM ,要更改标准输入流。因为 VIM 是一个互动的节目,它要求标准输入是控制台。

By piping into vim, you are changing the standard input stream. Because vim is an interactive program, it requires the standard input to be the console.

如果您要查看在vim,你应该告诉它,你正在阅读从标准输入文件(由提供参数 -

If you want to view in vim, you should tell it you are reading the file from stdin (by supplying the argument -):

history | vim -

另外,你可以只使用更多

history | more
history | less

后两个是preferable。如果你管进入 VIM 后,它会看到你的文件,作为修改,所以你不能用直退出:Q 命令。相反,你必须武力退出:!:Q ,这是一个有点笨重

These latter two are preferable. If you pipe into vim, it will see your "file" as having modifications, and so you can't quit with a straight :q command. Instead you have to force quit by :q!, which is a bit clunky.

在另一方面,你可以退出的更多只需键入。看看男人页的这两个节目。您将使用他们制造了很多。

On the other hand, you can exit more or less just by typing q. Have a look at the man-page for these two programs. You'll use them a lot.

由于在意见建议罗素·席尔瓦,你可以打开的 VIM 在只读模式下,当你从标准输入读取。只需提供 -R 参数。然后你就可以正常退出,而无需覆盖:

As recommended by Russell Silva in the comments, you can open vim in read-only mode when you read from stdin. Just supply the -R argument. Then you can quit normally without needing the override:

history | vim -R -

这篇关于为什么不"历史| VIM"工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆