Dnia poniedziałek, 23 października 2006 16:25, Nikolai Weibull napisał: > On 10/23/06, Mikolaj Machowski <[EMAIL PROTECTED]> wrote: > > Hello, > > > > I understand that escape() was primarily designed to escape strings > > when passing to system functions, but personally I never used that and > > in didn't noticed such use in various scripts but very often it is > > used to escape various charaters in Vim's own regexp matching or > > passing one string to some other Vim command. > > > > Hence is the problem: when escaping ' with escape(), character is > > prepended with \ which doesn't make sense when passing it to other Vim > > command because proper way to escape it in Vim is doubling it with > > > > another '. Example:: > > :echo escape('as''df', '''') > > There should really be a third, optional, parameter to escape() where > you can specify what character to use for escaping.
That wouldn't be real solution because to escape ' you still (in most situations) would need two escape() calls. One for escape ' with ' and second for rest of characters with \. The best solution is providing info about context. Yakov: why so much contexts? for single and double quotes there is only difference in number of backslashes. Escaping in command line is rather problem of which character should be escaped (most notably space), not system of escaping. I'd like to see only one flag additional and one default: s - [default - for backward compatibility] "system" escaping with \ v - Vim escaping, ' for ' and possibly some other (future?) differences m.