vimgrep是vim自带的一个工具,类似于grep的用法就可以实现。比如要在当前目录查找word,使用如下:
如果想要递归查找所有下级目录里面,那么就用
另外,如果想要在使用是快捷查找当前光标下的字母,则只需要在vimrc中添加如下代码:
通过vimgrep查找到的结果会生成到quickfix中,如下图:

There are a lot of commands for quickfix as you have said, but I tend to find I only use a small subset of them:
:copen " Open the quickfix window
:ccl " Close it
:cw " Open it if there are "errors", close it otherwise (some people prefer this)
:cn " Go to the next error in the window
:cnf " Go to the first error in the next file
get back to the
Quickfix List
I type
Ctrl
+
W
You can also use :cc 2 (or any other number) to jump to, in this case, the second error in the quickfix window. Navigating with :cn, :cc 4, etc will put the cursor on the line in question.
本文介绍如何利用vim内置工具vimgrep进行文件搜索,包括递归查找所有子目录中的指定词汇,并提供了在vim配置文件中添加快速搜索当前光标下单词的方法。此外,还介绍了如何使用vim的quickfix窗口来导航搜索结果。
7465

被折叠的 条评论
为什么被折叠?



