Saturday, January 30, 2010

Re: command works interactively but does not work in script

On 12/12/09 23:20, Uday K2 wrote:
> Hello,
>
> I am using VIM (version 7.1) on a SUN (UNIX) machine.
>
> The following command works when I type it interactively
> but fails when I keep it in a script and use vim -s option.
>
> The command is:
> :g/^{\s*$/normal ^maf{%mb:'a,'bs/,//g/^M
> [Please note that the ^M is actually Cntrl-M or "Enter" key
> which I got by typing Cntrl-V<Return>]
>
> The above command typed interactively works perfectly.
>
> All the command is trying to do is delete all the commas
> within all the "{}" blocks of a given file. Other commas have to
> be kept. Just commas with in the "{}" blocks need to be
> deleted.
>
> When I store the above command in a script file, and use
> vim -s<script> <datafile>
> command, it does not do anything. It just searches for the
> grepped pattern. That is all.
>
> Also, is there any way to run VIM scripts in a non-interactive
> or batch mode. Please let me know.
>
> Thanks,
> Uday K2
>

In addition to :help -S which corresponds to what Ben said, see also
:help -s-ex which discusses the -es (or -e -s) switch to start Vim in
batch mode.

Best regards,
Tony.
--
Isn't it strange that the same people that laugh at gypsy fortune
tellers take economists seriously?

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

No comments:

Post a Comment