vim grep

来源:互联网 发布:excel怎么做数据筛选 编辑:程序博客网 时间:2024/06/02 03:47



:help grep

1. 内部 grep
:vim  :vimgrep
vim  {pattern}  {file}
eg: 
    vim  dqbuf  stack/**/*.c
cmd ":set noic" , and then grep , will ignorecase to grep

    vimgrep有两种使用的方式:
    1)将匹配模式放到//之间:这样情况下,使用vim的正则模式来进行匹配
       命令格式::vim[grep][!] /{pattern}/[g][j] {file}
例子:
       :vim /function demo/ *.c        在当前目录的.c文件中,搜索function demo
       :vim /function demo/ **/*.c     在任意目录的.c文件中,搜索function demo
       :vim /function demo/ **/*.{h,c} 在任意目录的.c和.h文件中,搜索function demo
       :vim /\cfunction demo/ **/*.c   使用\c,不区分大小写
       :vim /\Cfunction demo/ **/*.c   使用\C,区分大小写
       :vim /function demo/j *.c       只更新quickfix,不跳转到第一个搜索结果
       :vim /function demo/g *.c       一行中若有多个匹配,每个都要单独显示一行
    2)直接加匹配模式:这种情况下只能搜索ID,举个例子,就不详细说了
       :vimgrep Error *.c

2 grep.vim

":Rgrep -i demo" and then press ENTER

0 0