Thursday, August 20, 2009

Re: Applying 4 commands repetetively

> I want to apply the same 4 commands to about 500 different files, and since
> its the same commands in the same order each time, I don't want to
> repetetively type the commands over and over again.
>
> I want to do:
>
> vi 1*
>
> dd
> :set local noswapfile undolevels=-1
> :%join!
> :n
>
> dd
> :set local noswapfile undolevels=-1
> :%join!
> :n
>
> dd
> :set local noswapfile undolevels=-1
> :%join!
> :n
>
> ....
>
> over and over again until there are no longer any more files.
>
> Is this possible in vim ??

Yep...you'll want to read up on "argdo" (":help argdo") which
would allow you to dosomething like

vi 1*
set noswapfile undolevels=-1 " no need to make them local
:argdo 1d | %j! |w

Don't forget that if you leave them (with ":n"), you'll want to
write the buffer (added in mine with "| w"). I assume that by
turning off swapfile/undolevels, your files are large so you
don't want to use 'hidden' to keep the changes and then write
them later.

-tim

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

No comments:

Post a Comment