Searching Files

2021-05-04  本文已影响0人  一口亅

vim中打开文件——edit

:edit *.yml<Tab>
:edit **/*.md<Tab>
*是当前文件夹,**可以实现递归搜索

搜索文件——find

相对于edit,find可以查找路径下的文件
通过 :set path? 发现默认下的路径:

path=.,/usr/include,,

通过在vimrc中添加路径快速读取文件

:set path+=$PWD/**

grep——文件中搜索

internal grep

:vim /pattern/ file

e.g. 在app/controllers/目录中的所有ruby文件(.rb)中查找所有出现的“breakfast”字符串:
:vim /breakfast/ app/controllers/*/.rb

搜索之后的命令

:copen        Open the quickfix window
:cclose       Close the quickfix window
:cnext        Go to the next error
:cprevious    Go to the previous error
:colder       Go to the older error list
:cnewer       Go to the newer error list
To learn more about quickfix, check out :h quickfix.

external grep

:grep -R "lunch" app/controllers/

Browsing Files With Netrw

fzf——搜索插件

上一篇 下一篇

猜你喜欢

热点阅读