Monday, May 24, 2010

Re: how to insert two lines at the same place in many files

On 05/24/2010 04:33 PM, Aryeh M. Friedman wrote:
> I have over 300 files that need the following done to them:
>
> at line X insert the following two lines:
>
> xxx [foo]
> xxx ack
>
> where [foo] is the fully qualified path the the file with the /'s
> converted to .'s

assuming you've started vim with your 300 files as arguments:

vim *.txt

you can then use (assuming you want to put them at line 123)

:set hidden
:argdo 123put='xxx ['.expand('%:p').\"]\nxxx ack\"

You can then review the files to make sure they're what you want,
and then use

:wall

to write all the files back out with the modifications.

-tim


--
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