>> I think you may be looking for the zero-width atoms in the
>> "\%#c" family, so you might search for something like
>> 
>> :%s/\%33cABCD/FGHI/
> 
> that works if I execute the command in the normal mode in VIM.
> Now my next question is:
> 
> How can I use the %s command from a VIM script in order to
> modify a given line of a file?

For the most part, any Ex command (beginning with a colon) also
functions as a vimscript command.  Thus, you can simply omit the
colon in a vimscript:

        function! foo()
                1,10s/\%33cABCD/FGHI/
        endfunction

will replace ABCD (at position 33) with FGHI from lines 1-10.
You don't even *have* to omit the colon, but it's easier to read
scripts without it.  The line-numbers are any range, so you can use

        %s/...

for the whole file, or

        1/int main/,$s/...

to do the replacements from "int main" through the end of the
file.  Or what have you.  All sorts of power/flexibility
available with Ex commands. :)

-tim

PS:  Please, as a courtesy, don't top-post...it makes it hard to
follow.  I've changed my reply to incorporate inline commenting.






Reply via email to