vimgrep查找文件里面的内容


:vimgrep /some pattern/  `find some_path -type f`

"The window opened by vim on these commands is called the QuickFix
:copen
:cnext
:cprev
:cc
:cf <file>
:cclose


"This will invoke an external grep
:grep pattern"Or you can do grep externally in a terminal and collect 
"its result in a file.
"Ensure to do grep -nH to get filename and line numbers
:cfile file_having_grep_results"Note that vim jumps to first result right on :cf. 
"To view the results
:copen

:copen      :lopen
:cnext      :lnext
:cprev      :prev
:cc         :ll
:cf <file>  :lf <file>

"Load into quickfix. vimgrep is vim itself doing a grep, 
"  instead of using a external grep
"This is okay in our case, as the current file is already a 
"  buffer in vim's memory
:vimgrep /pattern/ %"Or if we want in location window
:lvimgrep /pattern/ %
阅读量: 452
发布于:
修改于: