On Jun 21, 7:49 am, ZyX <[email protected]> wrote:
> While trying to purge comment lines inside a variable, I
> encountered the following problem:
>
>     :echo substitute("a\nb", '[\n]', '<NL>', 'g')
>     a<NL>b
>     :echo substitute("a\nb", '[^\n]', '<!NL>', 'g')
>     <!NL><!NL><!NL>

:help /collection says

     The end-of-line is also matched when the collection starts with
     "^"!  Thus "\_[^ab]" matches the end-of-line and any character
     but "a" and "b".  This makes it Vi compatible: Without the "\_"
     or "\n" the collection does not match an end-of-line.

I suspect the behaviour you've noticed is a consequence of this
reasoning.  Whether it should apply to newlines within the text is
beyond me presently, I'd have to consider lots of uses, consume
much coffee, and scratch my head till it bleeds.

HTH, John

-- 
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