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

Re: Substitute in a bunch of files

Expand Messages
  • Douglas L . Potts
    ... If you open a bunch of files like this: % vim file1 file2 file3 ... And want to do the substitute, you would use argdo. If you opened vim, and then started
    Message 1 of 2 , Feb 27, 2002
    • 0 Attachment
      On Tue, Feb 26, 2002 at 04:31:49PM -0800 yahoogroups@... wrote:
      > I want to run a substitute on a bunch of *.c files in a directory.
      >
      > What is the recommended approach?
      >
      > :cd directory
      > :n *.c
      > :argdo! %s/old/new/g/|update
      >
      > When would I use "bufdo" as opposed to "argdo"?
      If you open a bunch of files like this:
      % vim file1 file2 file3

      or open vim and do:
      :args file1 file2 file3

      And want to do the substitute, you would use argdo.

      If you opened vim, and then started editting other files this way:
      % vim
      :e file1
      :e file2

      Then you would want to use bufdo.

      Specifically, argdo limits the files to those that you intentionally
      opened. OTOH, bufdo would operate over any file that was 'hanging out'
      in your buffer list, like help files, etc.

      (BTW, sometimes :windo can be just as helpful as :argdo).

      HTH,
      -Doug

      --
      *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
      Douglas L. Potts
      Any resemblance between the above views and those of my employer, my
      terminal, or the view out my window are purely coincidental. Any
      resemblance between the above and my own views is non-deterministic.
      The question of the existence of views in the absence of anyone to hold
      them is left as an exercise for the reader. The question of the
      existence of the reader is left as an exercise for the second god
      coefficient. (A discussion of non-orthogonal, non-integral polytheism
      is beyond the scope of this article.) -Ralph Jennings
      GPG Fingerprint: 768A EEF8 197A 4C9A 5EF7 DA5B 464C 97DF DCD5 68C2
      *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    Your message has been successfully submitted and would be delivered to recipients shortly.