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

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

Expand Messages
  • glts
    Mar 5, 2013
      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).

      David B├╝rgin

      --
      --
      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.
    • Show all 2 messages in this topic