Eric Smith wrote:
I am using the following to search all buffers for "foo".
b1|bufdo exec search("foo" , flags)

This stops at the last match.  How do I stop at the first match?

thanx

The following works, I think, but it also saves modified buffer. It won't search [No Name] buffers. It may fail if you have named buffers not corresponding to a file, like directory-browsing buffers or options-window buffers. It might be more robust with argdo instead of bufdo.

If you can express the names of the files you want to search as a space-separated list of file names (possibly with wildcards), the first two lines below are not necessary.

        :let buflist = ""
        :bufdo let buflist .= " " . expand("%:p") | silent! update
        :exe "vimgrep /pattern/g" buflist


Best regards,
Tony.

Reply via email to