On Thu, May 25, 2006 at 02:46:32PM -0400, Mike Blonder wrote: > On Thu, 2006-05-25 at 14:05 -0400, James Vega wrote: > > On Thu, May 25, 2006 at 01:59:31PM -0400, Mike Blonder wrote: > > > Hi. > > > > > > I cannot find a good example in the documentation that would help me use > > > VIM to accomplish what I need to do: > > > > > > I need to add 6 lines to each of thousands of files. The location for > > > the lines to be added is the same and definable in a command. Anybody > > > have any ideas as to a straightforward way to get this done? I've tried > > > copying the lines to a register and then inserting the register text > > > into an argdo command, > > > > You were on the right track. If you have all the text in a register, > > then you can just use the :put command to do what you want. For > > example, if the text was in register a and you wanted to put it after > > line 24 in every file: > > > > :argdo 24put a > > > > James > > Thanks for the tips. > > the put command does NOT seem to work. The problem is that the line > number will change, from file to file, while the pattern will not. When > I try > > argdo <\/body>P a [to put the contents of register a before the pattern > </body>] I get a trailing characters error message.
First off, I was referring to the ex command :put, not the normal
command p. The ex command equivalent of P is :put!.
Second, argdo expects an ex command to run. What it sees is you trying
to run ':<' with the trailing characters '\/body>P'.
What you want to do is specify a range that searches for the line with
'</body>' on it. As shown in ":help range", you can do this as follows:
:/<\/body>/{command}
Which means your final command would be:
:/<\/body>/put! a
This assumes that you always want the text placed immediately before the
first '</body>' in the file.
HTH,
James
--
GPG Key: 1024D/61326D40 2003-09-02 James Vega <[EMAIL PROTECTED]>
signature.asc
Description: Digital signature
