Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Populate <code>:args</code> from a shell command</h2> <p>It's possible (on some operating systems<sup>1</sup>)) to supply the files for <code>:args</code> via a shell command.</p> <p>For example, if you have ack<sup>2</sup> installed,</p> <pre><code>:args `ack -l pattern` </code></pre> <p>will ask ack to return a list of files containing 'pattern' and put these on the argument list.</p> <p>Or with plain ol' grep i guess it'd be:</p> <pre><code>:args `grep -lr pattern .` </code></pre> <p><br/> You can then just use <code>:argdo</code> as described by the OP:</p> <pre><code>:argdo %s/pattern/replacement/gce </code></pre> <p><br/></p> <h2>Populate <code>:args</code> from the quickfix list</h2> <p>Also check out <a href="https://stackoverflow.com/a/5686810/2004045">nelstrom's answer</a> to a related question describing a simple user defined command that populates the arglist from the current quickfix list. This works great with many commands and plugins whose output ends up in the quickfix list (<code>:vimgrep</code>, <code>:Ack</code><sup>3</sup>, <code>:Ggrep</code><sup>4</sup>).</p> <p>The sequence to perform a project wide search could then be done with:</p> <pre><code>:vimgrep /pattern/ **/* :Qargs :argdo %s/findme/replacement/gc </code></pre> <p>where <code>:Qargs</code> is the call to the user defined command that populates the arglist from the quickfix list.</p> <p>You'll also find links in the <a href="https://stackoverflow.com/a/5686810/2004045">ensuing discussion</a> to simple plugins that get this workflow down to 2 or 3 commands.</p> <h2>Links</h2> <ol> <li><strong>:h {arglist}</strong> - vimdoc.sourceforge.net/htmldoc/editing.html#{arglist}</li> <li><strong>ack</strong> - <a href="http://betterthangrep.com/" rel="nofollow noreferrer">betterthangrep.com/</a></li> <li><strong>ack.vim</strong> - <a href="http://github.com/mileszs/ack.vim" rel="nofollow noreferrer">github.com/mileszs/ack.vim</a></li> <li><strong>fugitive</strong> - <a href="http://github.com/tpope/vim-fugitive" rel="nofollow noreferrer">github.com/tpope/vim-fugitive</a></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload