Thursday, November 3, 2011

Re: vim command line use

On Nov 3, 2:11 pm, "Weissman, Eric (GE Energy Services)"
<eric.weiss...@ge.com> wrote:
> I have just come across vim for the first time and so I am probably
> asking an old question (but I didn't find it in the FAQ):
>
> Can vim be used as a command on a shell command line?   I would like to
> use it to search a list of files and substitute a new string for a
> pattern it finds, and then write the resulting file to a new filename
> for each file in the original list.
>

I agree with others that it sounds like sed, maybe combined with find,
is what you want.

But vim can do it to. To tell Vim to do something while invoking from
the command-line, any of the following will do the trick:

+"command"
-c "command"
--cmd "command"

The first two are equivalent, the third is subtly different in that it
acts before any config files are read IIRC. Check the :help entry for -
c and --cmd to be sure.

Also of interest for your particular problem, is the :argdo command.
Check out the help entry.

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