简体   繁体   English

在Emacs中搜索目录

[英]Search directories in Emacs

I recently switched from Eclipse to Emacs and one feature that I really miss is Eclipse file search. 我最近从Eclipse切换到Emacs,我真正想念的一项功能是Eclipse文件搜索。 It allows you to search a whole project very accurately (albeit very slowly) for a particular search term. 它使您可以非常精确地(尽管非常缓慢)搜索特定项目的整个项目。 In Emacs I have been using Mx rgrep but it doesn't seem to give reliable results. 在Emacs中,我一直在使用Mx rgrep但似乎无法给出可靠的结果。 For example, If I search for 0.1 it will not return results for lines of code containing '0.1' (a match surrounded by quotation marks). 例如,如果我搜索0.1,它将不会返回包含“ 0.1”(用引号引起来的匹配项)的代码行的结果。

Can anyone suggest a more accurate alternative to rgrep ? 任何人都可以建议使用rgrep更为准确的替代rgrep吗?

I recommend use "igrep" lib for searhing in files, you can find it here . 我建议在文件中使用“ igrep” lib进行搜索,您可以在这里找到它。 To start using add this rows to your .emacs file (don't forget to igrep.el to emacs-path, it can be ~/.emacs.d/ for example): 要开始使用,请将以下行添加到您的.emacs文件中(不要忘记将igrep.el添加到emacs-path,例如,它可以是〜/ .emacs.d /):

(require 'igrep)
(global-set-key "\C-cf" 'igrep-find)

So you can start search by using [C-cf], it ask pattern for file names in search, and query to search. 因此,您可以使用[C-cf]开始搜索,它会要求模式在搜索中提供文件名,然后查询进行搜索。 Hope it helps. 希望能帮助到你。

I recommend ack . 我建议ack It can intelligently ignore files you don't want to search (eg version control directories). 它可以智能地忽略您不想搜索的文件(例如,版本控制目录)。

I recommend beagrep if you are working on large projects such as linux kernel or android. 如果您正在处理大型项目,例如linux内核或android,我建议使用beagrep。

It takes a desktop search engine beagle and grep together, so common programming grep tasks can be done very quickly. 它需要桌面搜索引擎beagle和grep在一起,因此可以非常快速地完成常见的编程grep任务。 For eg, grepping for readlink in android source code can take me more than half an hour, with beagrep, it only takes half a second. 例如,在android源代码中对readlink进行grepping可能要花费我半个多小时,而使用beagrep则只需要半秒钟。

Check out my github page . 查看我的github页面

Mx multi-occur-in-matching-buffers takes a regex to select the buffers you wish to search in, and a second regex to search for the item you're looking for. Mx multi-occur-in-matching-buffers一个正则表达式来选择要搜索的缓冲区,并使用第二个正则表达式来搜索您要查找的项目。

A common workflow with emacs is to never (or only rarely) close a buffer in a project when working on that project, and so after you've been hacking around for a while, you'll likely have most files open anyway. emacs的常见工作流程是,在处理项目时,永远不要(或很少会)关闭项目中的缓冲区,因此,经过一段时间的黑客攻击,无论如何,您很可能会打开大多数文件。 Of course, if you don't work like this, then using multi-occur... is of less use. 当然,如果您不这样工作,则使用multi-occur...的用处较小。

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

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