On Fri, Oct 16, 2009 at 6:06 PM, Dexter Douglas <[email protected]> wrote:

>
> Hello,
>
> I have a problem with an ex script that contains a self-referencing
> @-macro.  I have reduced it to the silly example below.
>
> I have a test file.  It looks like this:
>
> a
> b
> c
> d
>
>
> When I run the script, I want this for the results:
>
> a1
> hello
> b1
> hello
> c1
> hello
> d1
> hello
>
>
> Here is the test script that I am working on.
>
> :1
> :i
> :s/\(.*\)/\11/|a^Mhello^M.^M|+|@c
> .
> :delete c
> :@c
> ":w new.txt
> ":q!
>
>
> When I open the file and source this script, it produces the
> results that I want.  But when I uncomment the write and
> quit lines, the script does not run as expected.
>
> It produces this new.txt:
>
> a1
> hello
> b
> c
> d
>
>
> As a matter of fact, placing any command after the ":@c" line
> seems to cause the script to fail.
>
> Does anyone understand why the script works when I comment out
> the lines below ":@c", but does not otherwise?
>
> I am using Vim version 7.2.22.
>
> Thanks.
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> >
>
just insert a newline as part of the :s command -

 :%s/\(.*\)/\11\rhello/

this will do the whole edit in one go.

-- 
Christopher Suter
www.grooveshark.com

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

Reply via email to