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

Re: Patch: Make :vimgrep // * reuse the last search pattern

Expand Messages
  • Bram Moolenaar
    ... Thanks! -- How To Keep A Healthy Level Of Insanity: 13. Go to a poetry recital and ask why the poems don t rhyme. /// Bram Moolenaar -- Bram@Moolenaar.net
    Message 1 of 2 , Mar 5, 2013
    • 0 Attachment
      David B├╝rgin wrote:

      > The commands :s//string/, :g//, and :sort // all use the last search
      > pattern when an empty pattern is given. :vimgrep // *, however, does
      > not.
      > The attached patch makes :vimgrep // * behave like the other search
      > commands.
      > Details
      > -------
      > Trying and refining a search pattern and then using it with :s//string/
      > and :g// is a common editing pattern in Vim. But this doesn't work with
      > :vimgrep. Surprisingly, :vimgrep // * matches *everywhere*.
      > Why does it match everywhere? Regdump() output shows that "//" is
      > compiled to the following regexp:
      > regcomp():
      > 1:BRANCH(7)
      > 4:NOTHING(7)
      > 7:END(0)
      > All Vim puts in the compiled regexp program is a zero-width NOTHING
      > atom. NOTHING doesn't assert anything and matches the empty string, i.e.
      > everywhere (like :vimgrep /\ze/ *).
      > As far as I am aware, this behaviour is not documented. At least for
      > :vimgrep it doesn't serve any purpose. (In fact, I can't think of any
      > situation where a completely empty regexp would be appropriate.)
      > The attached patch makes :vimgrep reuse the last search pattern, in the
      > same way :g and :s do (and :sort).


      How To Keep A Healthy Level Of Insanity:
      13. Go to a poetry recital and ask why the poems don't rhyme.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ an exciting new programming language -- http://www.Zimbu.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    Your message has been successfully submitted and would be delivered to recipients shortly.