68564Patch: Make :vimgrep // * reuse the last search pattern
- Mar 5, 2013The commands :s//string/, :g//, and :sort // all use the last search
pattern when an empty pattern is given. :vimgrep // *, however, does
The attached patch makes :vimgrep // * behave like the other search
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:
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).
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.
- Next post in topic >>