On Thursday 23 June 2005 17:54, Tzafrir Cohen wrote:
> > I found out that I am unable to search or/and replace
> > automatically the & character in vim. The command: /\& paints
> > every character in the file.
I think you confused the two parts of s///:
- The search part is a regular expression and & does not
need escaping (it's not special for regex).
- In the replacement part, ampersand *does* have special
meaning -- the string that was matched by the LHS. If
you want a litteral & in the RHS than you need to escape it.
> Seems you've hit the magic. See, e.g.
> ...
> I must admit I don't fully understand it.
The magic feature is one of the most stupid features of the old vi.
When it's off It "dumb-down" vi, so that some common characters are
not special in regex and are activated by backslash. The problem is
that even with magic turned on, some characters need to be treeted
in this special way (e.g: + has to be \+ and (, ) has to be \(, \) etc.)
Why is it stupid? Because in every place in Unix/Linux we know that:
"A backslash before a non-letter character turns its special
meaning off"
Except that now it becomes:
"... unless you work in vi and the character is +, (, ), ...
and/or the 'magic' setting is off, or Bill Joy was on bad
mood the day he wrote this feature etc."
Oops, an important disclaimer is due (before holy wars begin) --
I am an avid vi/vim user since BSD 4.1 and love every moment, but
sometimes even our beloved ones have mistakes ;-)
--
Oron Peled Voice/Fax: +972-4-8228492
[EMAIL PROTECTED] http://www.actcom.co.il/~oron
ICQ UIN: 16527398
The National Multiple Sclerosis Society of America recently started an
advertising campaign with the slogan "MS: It's not a software company".
Seasoned IT professionals will have no trouble telling the two MS's
apart. One is a debilitating and surprisingly widespread affliction
that renders the sufferer barely able to perform the simplest task. The
other is a disease.
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]