如何在 Vim 中搜索打开的缓冲区? [英] How do I search the open buffers in Vim?

查看:67
本文介绍了如何在 Vim 中搜索打开的缓冲区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在当前在 vim 中打开的所有文件中搜索文本,并在一个地方显示所有结果.我猜有两个问题:

  • 我无法将打开的文件列表传递给 :grep/:vim,尤其是不在磁盘上的文件名;
  • :grep -C 1 text 的结果在 quickfix 窗口中看起来不太好.

这是在 Sublime Text 2 中多文件搜索的一个很好的例子:

有什么想法吗?

解决方案

:bufdo vimgrepadd 线程 % |科本

quickfix 窗口可能不适合您,但它比 ST2 的结果面板"功能强大得多,这仅仅是因为您可以在跳转到位置时保持打开和可见,并在它不存在的情况下与它进行交互.

I'd like to search for text in all files currently open in vim and display all results in a single place. There are two problems, I guess:

  • I can't pass the list of open files to :grep/:vim, especially the names of files that aren't on the disk;
  • The result of :grep -C 1 text doesn't look good in the quickfix window.

Here is a nice example of multiple file search in Sublime Text 2:

Any ideas?

解决方案

Or

:bufdo vimgrepadd threading % | copen

The quickfix window may not look good for you but it's a hell of a lot more functional than ST2's "results panel" if only because you can keep it open and visible while jumping to locations and interact with it if it's not there.

这篇关于如何在 Vim 中搜索打开的缓冲区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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