On Sat, 13 Mar 2010 01:18:54 +0800, Christian Brabandt wrote:
Hi Tom!
On Fr, 12 Mär 2010, Tom Link wrote:
The backslash also has a special meaning in the substitution (eg if
you want to insert \n). This should work:
%s/.\+/\=escape(submatch(0), '\')
That was what I thought I have to do. So I have to remeber to always
escape it.
I still consider it a bug. If I want backslashes to be expanded, I'll
use printf and I think submatch(0) should return the match as it was
found.
The thing is, I often use submatch(0) when I don't want to alter the
text. And until now, I wasn't aware of the fact, that submatch changes
it.
I don't think it's submatch(0) which changes the backslashes; it's
sub-replace-expression that does the job, and was documented, see:
:h sub-replace-special
From what I've understood, the submatch(0) returns exactly what it
matches, however the backslashes got removed via being evaluated in the
sub-replace-expressions. For example, without using submatch(), if you try:
:%s/.\+/\='\a\b\c\d\e'/
you would got 'abcde' without backslashes either.
HTH
--
Dasn
--
You received this message from the "vim_use" 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