Emacs中的文件查找

1,在本文件中查找

list-matching-lines 命令会列出本文件中所有出现text的地方。下面是它的一个输出示例:

1
2
3
4
5
6
7
8
7 matches for "ngx_http_wait_request_handler" in buffer: ngx_http_request.c                                            
     13:static void ngx_http_wait_request_handler(ngx_event_t *ev);
    312:    rev->handler = ngx_http_wait_request_handler;
    374:ngx_http_wait_request_handler(ngx_event_t *rev)
    740:        rev->handler = ngx_http_wait_request_handler;
    741:        ngx_http_wait_request_handler(rev);
    796:        c->read->handler = ngx_http_wait_request_handler;
    801:        ngx_http_wait_request_handler(c->read);
  将光标定位到某一行再按回车键会跳转到该行。

 

2,在一组文件或者一个目录中查找

M-x grep 命令会在一组文件或者一个目录中查找所有text出现的地方。

默认情况下,grep会在当前文件所属的目录下查找,

grep -nH -e "ngx_http_ssl" *.c 会在当前目录的所有.c文件中查找ngx_http_ssl出现的地方,输出跟上面的输出类似,将光标定位到某一行再按回车会跳转到该行。

 

M-x rgrep 的交互性会更好。它会先让你输入要查找的字符串,然后让你输入文件,最后让你选择查找的目录。上面的输入都可以用正则表达式来写。

 

 

3,在一个目录中查找文件

M-x find-name-dired 

  

原文地址:https://www.cnblogs.com/zdq9682950/p/6702911.html