Andy Wokula wrote:

> Am 23.03.2010 16:27, schrieb Bram Moolenaar:
> >
> > Patch 7.2.407
> > Problem:    When using an expression in ":s" backslashes in the result are
> >         dropped. (Sergey Goldgaber, Christian Brabandt)
> > Solution:   Double backslashes.
> > Files:          src/regexp.c
> 
> I found a bug (two lines of text below):
> 
> abc\
> def
> 
>      :s/abc\\\ndef/\=submatch(0)/
>      " result:
> 
> ab...@def
> 
> (^@ is one character)

Yes, that looks like a bug.

> BTW: How do you now insert a literal <CR> or a literal <NL>?
> 
> abc<CR>def
>      :s/.*/\="abc\\\<CR>def"/

        s/.*/\="abc<CR>def"/

No need for backslashes.  If you want to get \<CR> then you need to use
two backslashes:
        s/.*/\="abc\\<CR>def"/

> (or :s/.*/\="abc\\\rdef"/
>   or :s/.*/\='abc\^Mdef'/    where ^M was inserted with <C-V><CR>)
> 
> It now breaks the line.
> 
> 
> What about backwards compatibility?

Yes, that worried me too.  But the example of replacing literal text by
using submatch(N) is most convincing.  The basic idea now is that the
expression returns literally what needs to be inserted.

Only problem now is to make it possible to insert a line break.  That
would be a NUL, but that also terminates the string...

> I had a script dealing with conversion of binary data, it's (most
> probably) broken now.
> 
> I also see updates for other scripts due to this patch, e.g.
> Vimscript #162, auctex.vim, v2.2.1 -> v2.2.2

Not nice.  So do we prefer the old solution?  That will also allow for
inserting a line break again.

-- 
"Thou shalt not follow the Null Pointer, for at its end Chaos and
Madness lie."

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
You received this message from the "vim_dev" 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

Raspunde prin e-mail lui