简体   繁体   English

怎么做:w!tee在Vim工作

[英]How does :w !tee work in Vim

This answer states that :w !tee writes current buffer to stdout. 这个答案表明:w !tee将当前缓冲区写入stdout。 Why and how does it work? 为什么以及如何运作? Can I write :x !tee or :w !cat ? 我可以写:x !tee:w !cat What's exclamation mark meaning in this case? 在这种情况下,感叹号是什么意思? (I assume it's not forcing operation.) Does it work only if tee command exists (not on Windows)? (我假设它不是强制操作。)只有在存在tee命令(不在Windows上)时才能工作吗?

! tells vim that it's a shell command and not a filename. 告诉vim它是一个shell命令而不是文件名。 So :w !tee or :w !cat gives the vim buffer to those commands as input. 所以:w !tee:w !cat将vim缓冲区作为输入提供给那些命令。 They in turn send the buffer content to stdout . 他们又将缓冲区内容发送到stdout

Try :w !wc -l , this will give you number of lines in your buffer printed on stdout . 尝试:w !wc -l ,这将为您提供在stdout打印的缓冲区中的行数。

You can also read output from a command into vim buffer. 您还可以将命令的输出读入vim缓冲区。 You can use read command with a shell command. 您可以将read命令与shell命令一起使用。 For example, :read !date executes the date command on shell and sends the output back to vim buffer. 例如, :read !date在shell上执行date命令并将输出发送回vim缓冲区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM