简体   繁体   English

如何在Vim的命令行模式下搜索和复制Ex命令的输出?

[英]How to search and copy output of Ex commands run in command-line mode in Vim?

Some command-line mode commands (ie the Ex commands, not shell commands) in Vim can produce output that are several line longs. Vim中的某些命令行模式命令(例如Ex命令,而不是shell命令)可以产生几行长的输出。 I have two questions about it. 我有两个问题。

  • How can I search for a particular word in it? 如何在其中搜索特定单词?
  • How can I copy something from it and paste it into the buffer I am editing? 如何复制内容并将其粘贴到我正在编辑的缓冲区中?

I see that in my Vim, the more pager is used when the output is more than one screen full, so I think that brings more complexity to this question because the solution may differ when the more pager is involved. 我看到在Vim中,当输出大于一个屏幕满时,将使用more寻呼机,因此,我认为这会带来更多的复杂性,因为当涉及到more寻呼机时,解决方案可能会有所不同。

EDITED because I originally misunderstood the question: 编辑因为我最初误解了这个问题:

help :redir should tell you how to do it. help :redir应该告诉你怎么做。 For a specific example: 对于一个特定的例子:

:redir @h
:silent highlight
:redir END
"hp

Start redirection to the register h , run your command without showing it on the screen (and without running it through the pager), stop the redirection, paste the contents of the h register. 开始重定向到寄存器h ,运行命令而不在屏幕上显示它(并且不通过分页器运行它),停止重定向,粘贴h寄存器的内容。

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

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