Loading ...
Sorry, an error occurred while loading the content.

Antwort: grep in all buffers

Expand Messages
  • johann.pfefferl.jp@germany.agfa.com
    Hello, I have written two functions for that. Please keep in mind. I you have a hundreds of buffers the function crashes (At least for vim 5.7)!!! ... After
    Message 1 of 1 , Sep 7, 2001
    • 0 Attachment
      Hello,

      I have written two functions for that. Please keep in mind.
      I you have a hundreds of buffers the function crashes
      (At least for vim 5.7)!!!

      Do something like that on the 'ex' command line:

      :Bgrepall what-I-search-for

      After that you can use the quickfix commands (:cl, :cn, :cp, ....)
      to jump to the occurences of the search pattern.

      ""
      "" All Buffer grep
      ""
      function! Bgrepall_func(searchpattern)
      let i=1
      let flist = ''
      while i <= bufnr('$')
      if bufexists(i)
      let flist = flist .' '. bufname(i)
      endif
      let i=i+1
      endwhile
      exe "grep '" . a:searchpattern . "' " . flist
      endfunction
      com! -com=command -nargs=1 Bgrepall call Bgrepall_func(<q-args>)
      nmap grb :Bgrepall '<cword>'
      vmap grb y:Bgrepall <C-R>"

      ""
      "" All Windows grep
      ""
      function! Wgrepall_func(searchpattern)
      let flist = ''
      let endbuf=winnr()
      let nowbuf= -1
      while nowbuf != endbuf
      exe "norm\<c-w>w"
      let nowbuf=winnr()
      let flist = flist .' '. bufname("%")
      endwhile
      exe "grep '" . a:searchpattern . "' " . flist
      endfunction
      com! -com=command -nargs=1 Wgrepall call Wgrepall_func(<q-args>)
      nmap grw :Wgrepall '<cword>'
      vmap grw y:Wgrepall <C-R>"


      Hans
      --
      Dr.-Ing. Johann Pfefferl mailto:johann.pfefferl.jp@...
      Agfa-Gevaert AG Tel.: +49 89 6207-3524
      GF Laborgeraete, Entwicklung Software (LG-ESW) Sek.: +49 89 6207-3362
      Tegernseer Landstr. 161, D-81539 Muenchen Fax : +49 89 6207-7279
      __
      / / __ _ _ _ _ __ __
      / /__ / / / \// //_// \ \/ / -o)
      /____/ /_/ /_/\/ /___/ /_/\_\ /\\
      ...for IQs GREATER than 98... _\_v-





      "Kremer Markus (PN-SYS/DSA)" <Markus.Kremer@...> am 07/09/2001 13:39:55

      An: "'vim@...'" <vim@...>
      Kopie:
      Thema: grep in all buffers


      Hello,
      i work with many open buffers.
      is there a way of searching for a string in all open buffers, instead of
      just the current one?

      best regards

      Markus Kremer
    Your message has been successfully submitted and would be delivered to recipients shortly.