如何将缓冲区内容写入标准输出?
是否有机会将当前vim缓冲区的内容写入stdout?
Is there any chance to write the content of the current vim buffer to stdout?
我想使用 vim 来编辑通过 stdin 传递的内容 - 不需要临时文件来检索修改后的内容(在 Linux/Unix 上).
I'd like to use vim to edit content that was passed via stdin - without the need of a temporary file to retrieve the modified content (on Linux/Unix).
执行退出或保存的插件/脚本是否可能将缓冲区内容放入标准输出?
Is it possible that a plugin/script - that act on quit or save put the buffer content to stdout?
既然你使用 Linux/Unix,你可能也有兴趣尝试一下 moreutils.它提供了一个名为vipe
的命令,它从stdin
中读取,让你编辑$EDITOR
中的文本,然后将修改后的文本打印到标准输出代码>.
Since you use Linux/Unix, you might also be interested in trying out moreutils. It provides a command called vipe
, which reads from stdin
, lets you edit the text in $EDITOR
, and then prints the modified text to stdout
.
因此请确保将编辑器设置为 Vim:
So make sure you set your editor to Vim:
export EDITOR=vim
然后你可以试试这些例子:
And then you can try these examples:
cat /etc/fstab | vipe
cut -d' ' -f2 /etc/mtab | vipe | less