On Oct 16, 5: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
>
I can verify this using Vim 7.2.79 (latest from the package manager on
Ubuntu Jaunty). I'll check in the latest patched version I have on
Windows sometime later.
The really interesting thing is, if you uncomment the :w but not
the :q, you can see that the original buffer gets modified as
expected, but the written file only modifies the first line, as shown.
A slightly more intuitive script does the same:
1
let @c = ':s/\(.*\)/\11/|a^Mhello^M.^M|+|@c'
@c
w! new.txt
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---