html tool

2012年12月5日星期三

查找结果单独列出一行 :lvimgrep /pattern/ % | lopen


查找结果单独列出一行
  • :lvimgrep /pattern/ % | lopen


    解释
    • lvimgrep 

      来源:http://3y.uu456.com/bp-ff0b583067ec102de2bd8959-7.html
       Grep 的名字来源于”g/re/p”,”re”是正则表达式(regex)的意思,”p”是打印,也就是把匹 配正则表达式的行打印出来。[popexizhi:嘻嘻多问一句g是什么啊? 不过很谢谢,现在至少知道re p了:)]
       vim 既可以使用外部的 grep 程序,也可以使用内部集成的 grep 功能。 使用集成的 grep 命令非常简单,通常使用格式为:
       :vimgrep /main/gj **/*.c 在上面的例子里,我们使用 vim 内部集成的 grep 功能,在当前目录及其子目录树的所有 c 文件中查找 main 字符串,如果一行中 main 出现了多次,每个匹配都计入;在查找到后, 不立即跳转到第一个匹配的地方。 使用内部集成的 grep 功能速度要比外部 grep 慢一些,因为它会打开每个文件,对其进行 检查,然后关闭
      [popexizhi:在本地测试了一下,这个方式无法打开子目录的文件,也就是无法递归查找,不过这个当前目录就很不错了:)
      两个问题:
      1.gj 分别是什么?
      2.本地测试时有文件提示无法打开why?]


    目的:快速从map中提取[add/edit/change tc] 的内容与原因  
  •      
    【后记】
    1.gj 分别是什么?
    来源:http://vim.wikia.com/wiki/Find_in_files_within_Vim
     Use of grep and lgrep depend on the external application they point to, but use of vimgrep and lvimgrep is as follows:
    :vim[grep][!] /{pattern}/[g][j] {file} ...

    The 'g' option specifies that all matches for a search will be returned instead of just one per line, and the 'j' option specifies that Vim will not jump to the first match automatically.
    For example, to search for the words "house" or "home" in all .txt files in the current directory, use:
    :lvim /\<\(house\|home\)\>/gj *.txt

    [popexizhi: 测试了一下j,是的如果使用的话会将同一行中的第二个也发现,不使用就没有。g还没有测试]    



    【过程中发现的新问题和使用情况】      
    /[^\(a\)]\+$/
    查找不包含a的字符的全部行的匹配
    [?][popexizhi:一个很奇怪的问题,如果使用时不指定$,一行开始不为a的部分就会被匹配上,可$不是结束符吗?:)]    

    --------------------------------------------------------------
    【popexizhi:感觉自己blog中的格式真烂,乱死了没有思路,显示和thinking map中相差很多,如何写出好格式呢?这是个应该思考的问题啊!】

没有评论:

发表评论