Tuesday, October 26, 2010

Re: execute command in [vim]grep-results ?

> Now I wonder if there's a way to execute a command over all search-results
> in the quickfix or location-list?
> E.g.
> vimgrep 'define' **/*.rb
> and then on all files in the quickfix, or location list
> *quickfix_do* %s/define/def/g

trag[1] lets you select the lines you want and then run a command over
those lines.

The above example would run :s over the whole buffer. If this is what
you want, you could retrieve the lists with getqflist() or
getloclist(). You could then collect a list of files from the entries
in that list and then work on that list of files. I don't know of any
vim command that gives the list of files in the qfl/loclist right
away.

BTW, you should probably add matches for word boundaries to your
regexp (\<define\>) in order not to replace defineFoo with defFoo.

Regards,
Tom

[1] http://www.vim.org/scripts/script.php?script_id=2033

--
You received this message from the "vim_use" 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

No comments:

Post a Comment